You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/05/16 09:07:36 UTC
[1/8] incubator-ignite git commit: Revert "ignite-471: fixed NPE in
PortableMarshaller"
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-471 477dea6f4 -> 8a6dd007d
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/VisorArgListSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/VisorArgListSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/VisorArgListSpec.scala
index a581899..8b71918 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/VisorArgListSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/VisorArgListSpec.scala
@@ -25,48 +25,48 @@ import visor._
/**
* Test for visor's argument list parsing.
*/
-class VisorArgListSpec extends FunSpec with ShouldMatchers {
- describe("A visor argument list") {
- it("should properly parse 'null' arguments") {
- val v = parseArgs(null)
+class VisorArgListSpec extends FlatSpec with ShouldMatchers {
+ behavior of "A visor argument list"
- assert(v.isEmpty)
- }
+ it should "properly parse 'null' arguments" in {
+ val v = parseArgs(null)
- it("should properly parse non-empty arguments") {
- val v = parseArgs("-a=b c d -minus -d=")
+ assert(v.isEmpty)
+ }
+
+ it should "properly parse non-empty arguments" in {
+ val v = parseArgs("-a=b c d -minus -d=")
- assert(v.size == 5)
+ assert(v.size == 5)
- assert(v(0)._1 == "a")
- assert(v(0)._2 == "b")
+ assert(v(0)._1 == "a")
+ assert(v(0)._2 == "b")
- assert(v(1)._1 == null)
- assert(v(1)._2 == "c")
+ assert(v(1)._1 == null)
+ assert(v(1)._2 == "c")
- assert(v(2)._1 == null)
- assert(v(2)._2 == "d")
+ assert(v(2)._1 == null)
+ assert(v(2)._2 == "d")
- assert(v(3)._1 == "minus")
- assert(v(3)._2 == null)
+ assert(v(3)._1 == "minus")
+ assert(v(3)._2 == null)
- assert(v(4)._1 == "d")
- assert(v(4)._2 == "")
- }
+ assert(v(4)._1 == "d")
+ assert(v(4)._2 == "")
+ }
- it("should properly parse quoted arguments") {
- val v = parseArgs("-a='b 'c' d' -minus -d=")
+ it should "properly parse quoted arguments" in {
+ val v = parseArgs("-a='b 'c' d' -minus -d=")
- assert(v.size == 3)
+ assert(v.size == 3)
- assert(v(0)._1 == "a")
- assert(v(0)._2 == "b 'c' d")
+ assert(v(0)._1 == "a")
+ assert(v(0)._2 == "b 'c' d")
- assert(v(1)._1 == "minus")
- assert(v(1)._2 == null)
+ assert(v(1)._1 == "minus")
+ assert(v(1)._2 == null)
- assert(v(2)._1 == "d")
- assert(v(2)._2 == "")
- }
+ assert(v(2)._1 == "d")
+ assert(v(2)._2 == "")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/VisorFileNameCompleterSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/VisorFileNameCompleterSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/VisorFileNameCompleterSpec.scala
index e7333c6..9767fc4 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/VisorFileNameCompleterSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/VisorFileNameCompleterSpec.scala
@@ -25,34 +25,34 @@ import java.util
/**
* Test for visor's file name completer.
*/
-class VisorFileNameCompleterSpec extends FunSpec with ShouldMatchers {
- describe("A visor file name completer") {
- it("should properly parse empty path") {
- val c = new VisorFileNameCompleter()
+class VisorFileNameCompleterSpec extends FlatSpec with ShouldMatchers {
+ behavior of "A visor file name completer"
- val res = new util.ArrayList[CharSequence]()
+ it should "properly parse empty path" in {
+ val c = new VisorFileNameCompleter()
- c.complete("", 0, res)
+ val res = new util.ArrayList[CharSequence]()
- assertResult(new File("").getAbsoluteFile.listFiles().length)(res.size)
+ c.complete("", 0, res)
- res.clear()
+ assertResult(new File("").getAbsoluteFile.listFiles().length)(res.size)
- c.complete(null, 0, res)
+ res.clear()
- assertResult(new File("").getAbsoluteFile.listFiles().length)(res.size)
+ c.complete(null, 0, res)
- res.clear()
+ assertResult(new File("").getAbsoluteFile.listFiles().length)(res.size)
- c.complete(" ", 2, res)
+ res.clear()
- assertResult(new File("").getAbsoluteFile.listFiles().length)(res.size)
+ c.complete(" ", 2, res)
- res.clear()
+ assertResult(new File("").getAbsoluteFile.listFiles().length)(res.size)
- c.complete("help ", 5, res)
+ res.clear()
- assertResult(new File("").getAbsoluteFile.listFiles().length)(res.size)
- }
+ c.complete("help ", 5, res)
+
+ assertResult(new File("").getAbsoluteFile.listFiles().length)(res.size)
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/ack/VisorAckCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/ack/VisorAckCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/ack/VisorAckCommandSpec.scala
index b6a9608..6c6c829 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/ack/VisorAckCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/ack/VisorAckCommandSpec.scala
@@ -24,17 +24,17 @@ import org.apache.ignite.visor.commands.ack.VisorAckCommand._
* Unit test for 'ack' command.
*/
class VisorAckCommandSpec extends VisorRuntimeBaseSpec(2) {
- describe("A 'ack' visor command") {
- it("should properly execute w/o arguments"){
- visor ack()
- }
+ behavior of "A 'ack' visor command"
- it("should properly execute with arguments") {
- visor ack "Broadcasting!"
- }
+ it should "properly execute w/o arguments" in {
+ visor ack()
+ }
+
+ it should "properly execute with arguments" in {
+ visor ack "Broadcasting!"
+ }
- it("should print error message when not connected") {
- visor ack()
- }
+ it should "print error message when not connected" in {
+ visor ack()
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommandSpec.scala
index ec7d1b5..0a3a011 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommandSpec.scala
@@ -100,54 +100,54 @@ class VisorAlertCommandSpec extends VisorRuntimeBaseSpec(1) {
}
}
- describe("An 'alert' visor command") {
- it("should print not connected error message") {
- visor.close()
+ behavior of "An 'alert' visor command"
- checkOut(visor.alert("-r -t=5 -cc=gte4"), "Visor is disconnected.")
+ it should "print not connected error message" in {
+ visor.close()
- checkOut(visor.alert(), "No alerts are registered.")
- }
+ checkOut(visor.alert("-r -t=5 -cc=gte4"), "Visor is disconnected.")
+
+ checkOut(visor.alert(), "No alerts are registered.")
+ }
- it("should register new alert") {
- try {
- checkOut(visor.alert(), "No alerts are registered.")
+ it should "register new alert" in {
+ try {
+ checkOut(visor.alert(), "No alerts are registered.")
- matchOut(visor.alert("-r -t=5 -cc=gte4"), "Alert.+registered.")
+ matchOut(visor.alert("-r -t=5 -cc=gte4"), "Alert.+registered.")
- checkOut(visor.alert(), "No alerts are registered.", false)
- }
- finally {
- visor.alert("-u -a")
- }
+ checkOut(visor.alert(), "No alerts are registered.", false)
+ }
+ finally {
+ visor.alert("-u -a")
}
+ }
- it("should print error messages on incorrect alerts") {
- try {
- matchOut(visor.alert("-r -t=5"), "Alert.+registered.")
+ it should "print error messages on incorrect alerts" in {
+ try {
+ matchOut(visor.alert("-r -t=5"), "Alert.+registered.")
- checkOut(visor.alert("-r -UNKNOWN_KEY=lt20"), "Invalid argument")
+ checkOut(visor.alert("-r -UNKNOWN_KEY=lt20"), "Invalid argument")
- checkOut(visor.alert("-r -cc=UNKNOWN_OPERATION20"), "Invalid expression")
- }
- finally {
- visor.alert("-u -a")
- }
+ checkOut(visor.alert("-r -cc=UNKNOWN_OPERATION20"), "Invalid expression")
+ }
+ finally {
+ visor.alert("-u -a")
}
+ }
- it("should write alert to log") {
- try {
- matchOut(visor.alert("-r -nc=gte1"), "Alert.+registered.")
+ it should "write alert to log" in {
+ try {
+ matchOut(visor.alert("-r -nc=gte1"), "Alert.+registered.")
- Ignition.start(config("node-2"))
+ Ignition.start(config("node-2"))
- Ignition.stop("node-2", false)
+ Ignition.stop("node-2", false)
- checkOut(visor.alert(), "No alerts are registered.", false)
- }
- finally {
- visor.alert("-u -a")
- }
+ checkOut(visor.alert(), "No alerts are registered.", false)
+ }
+ finally {
+ visor.alert("-u -a")
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheClearCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheClearCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheClearCommandSpec.scala
index 6bb4993..2e51698 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheClearCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheClearCommandSpec.scala
@@ -75,43 +75,43 @@ class VisorCacheClearCommandSpec extends VisorRuntimeBaseSpec(2) {
cfg
}
- describe("An 'cclear' visor command") {
- it("should show correct result for default cache") {
- Ignition.ignite("node-1").cache[Int, Int](null).putAll(Map(1 -> 1, 2 -> 2, 3 -> 3))
+ behavior of "An 'cclear' visor command"
- val lock = Ignition.ignite("node-1").cache[Int, Int](null).lock(1)
+ it should "show correct result for default cache" in {
+ Ignition.ignite("node-1").cache[Int, Int](null).putAll(Map(1 -> 1, 2 -> 2, 3 -> 3))
- lock.lock()
+ val lock = Ignition.ignite("node-1").cache[Int, Int](null).lock(1)
- VisorCacheClearCommand().clear(Nil, None)
+ lock.lock()
- lock.unlock()
+ VisorCacheClearCommand().clear(Nil, None)
- VisorCacheClearCommand().clear(Nil, None)
- }
+ lock.unlock()
- it("should show correct result for named cache") {
- Ignition.ignite("node-1").cache[Int, Int]("cache").putAll(Map(1 -> 1, 2 -> 2, 3 -> 3))
+ VisorCacheClearCommand().clear(Nil, None)
+ }
+
+ it should "show correct result for named cache" in {
+ Ignition.ignite("node-1").cache[Int, Int]("cache").putAll(Map(1 -> 1, 2 -> 2, 3 -> 3))
- val lock = Ignition.ignite("node-1").cache[Int, Int]("cache").lock(1)
+ val lock = Ignition.ignite("node-1").cache[Int, Int]("cache").lock(1)
- lock.lock()
+ lock.lock()
- visor.cache("-clear -c=cache")
+ visor.cache("-clear -c=cache")
- lock.unlock()
+ lock.unlock()
- visor.cache("-clear -c=cache")
- }
+ visor.cache("-clear -c=cache")
+ }
- it("should show correct help") {
- VisorCacheCommand
+ it should "show correct help" in {
+ VisorCacheCommand
- visor.help("cache")
- }
+ visor.help("cache")
+ }
- it("should show empty projection error message") {
- visor.cache("-clear -c=wrong")
- }
+ it should "show empty projection error message" in {
+ visor.cache("-clear -c=wrong")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommandSpec.scala
index 4859a8f..4724006 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommandSpec.scala
@@ -36,6 +36,7 @@ import org.apache.ignite.visor.commands.cache.VisorCacheCommand._
* Unit test for 'events' command.
*/
class VisorCacheCommandSpec extends VisorRuntimeBaseSpec(1) {
+ behavior of "A 'cache' visor command"
/** IP finder. */
val ipFinder = new TcpDiscoveryVmIpFinder(true)
@@ -53,7 +54,7 @@ class VisorCacheCommandSpec extends VisorRuntimeBaseSpec(1) {
val arr = Seq(classOf[JavaInt], classOf[Foo]).toArray
- cfg.setIndexedTypes(arr: _*)
+ cfg.setIndexedTypes(arr:_*)
cfg
}
@@ -64,8 +65,7 @@ class VisorCacheCommandSpec extends VisorRuntimeBaseSpec(1) {
* @param name Grid name.
* @return Grid configuration.
*/
- override def config(name: String): IgniteConfiguration =
- {
+ override def config(name: String): IgniteConfiguration = {
val cfg = new IgniteConfiguration
cfg.setGridName(name)
@@ -81,51 +81,49 @@ class VisorCacheCommandSpec extends VisorRuntimeBaseSpec(1) {
cfg
}
- describe("A 'cache' visor command") {
- it("should put/get some values to/from cache and display information about caches") {
- val c = Ignition.ignite("node-1").cache[String, String]("replicated")
+ it should "put/get some values to/from cache and display information about caches" in {
+ val c = Ignition.ignite("node-1").cache[String, String]("replicated")
- for (i <- 0 to 3) {
- val kv = "" + i
+ for (i <- 0 to 3) {
+ val kv = "" + i
- c.put(kv, kv)
+ c.put(kv, kv)
- c.get(kv)
- }
-
- visor.cache()
+ c.get(kv)
}
- it("should run query and display information about caches") {
- val g = Ignition.ignite("node-1")
+ visor.cache()
+ }
- val c = g.cache[JavaInt, Foo]("replicated")
+ it should "run query and display information about caches" in {
+ val g = Ignition.ignite("node-1")
- c.put(0, Foo(20))
- c.put(1, Foo(100))
- c.put(2, Foo(101))
- c.put(3, Foo(150))
+ val c = g.cache[JavaInt, Foo]("replicated")
- // Create and execute query that mast return 2 rows.
- val q1 = c.query(new SqlQuery(classOf[Foo], "_key > ?").setArgs(JavaInt.valueOf(1))).getAll
+ c.put(0, Foo(20))
+ c.put(1, Foo(100))
+ c.put(2, Foo(101))
+ c.put(3, Foo(150))
- assert(q1.size() == 2)
+ // Create and execute query that mast return 2 rows.
+ val q1 = c.query(new SqlQuery(classOf[Foo], "_key > ?").setArgs(JavaInt.valueOf(1))).getAll()
- // Create and execute query that mast return 0 rows.
- val q2 = c.query(new SqlQuery(classOf[Foo], "_key > ?").setArgs(JavaInt.valueOf(100))).getAll
+ assert(q1.size() == 2)
- assert(q2.size() == 0)
+ // Create and execute query that mast return 0 rows.
+ val q2 = c.query(new SqlQuery(classOf[Foo], "_key > ?").setArgs(JavaInt.valueOf(100))).getAll()
- visor cache "-a"
- }
+ assert(q2.size() == 0)
- it("should display correct information for 'replicated' cache only") {
- visor cache "-n=replicated -a"
- }
+ visor cache "-a"
+ }
- it("should display correct information for all caches") {
- visor cache "-a"
- }
+ it should "display correct information for 'replicated' cache only" in {
+ visor cache "-n=replicated -a"
+ }
+
+ it should "display correct information for all caches" in {
+ visor cache "-a"
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommandSpec.scala
index 72642f7..6b1b62d 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/config/VisorConfigurationCommandSpec.scala
@@ -42,9 +42,9 @@ class VisorConfigurationCommandSpec extends VisorRuntimeBaseSpec(1) {
cfg
}
- describe("A 'config' visor command") {
- it("should print configuration for first node") {
- visor.config("-id8=@n0")
- }
+ behavior of "A 'config' visor command"
+
+ it should "print configuration for first node" in {
+ visor.config("-id8=@n0")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cswap/VisorCacheSwapCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cswap/VisorCacheSwapCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cswap/VisorCacheSwapCommandSpec.scala
index 8a0b0c8..f5af1d3 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cswap/VisorCacheSwapCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cswap/VisorCacheSwapCommandSpec.scala
@@ -69,21 +69,21 @@ class VisorCacheSwapCommandSpec extends VisorRuntimeBaseSpec(2) {
cfg
}
- describe("An 'cswap' visor command") {
- it("should show correct result for default cache") {
- Ignition.ignite("node-1").cache[Int, Int](null).putAll(Map(1 -> 1, 2 -> 2, 3 -> 3))
+ behavior of "An 'cswap' visor command"
- visor.cache("-swap -c=<default>")
- }
+ it should "show correct result for default cache" in {
+ Ignition.ignite("node-1").cache[Int, Int](null).putAll(Map(1 -> 1, 2 -> 2, 3 -> 3))
- it("should show correct result for named cache") {
- Ignition.ignite("node-1").cache[Int, Int]("cache").putAll(Map(1 -> 1, 2 -> 2, 3 -> 3))
+ visor.cache("-swap -c=<default>")
+ }
+
+ it should "show correct result for named cache" in {
+ Ignition.ignite("node-1").cache[Int, Int]("cache").putAll(Map(1 -> 1, 2 -> 2, 3 -> 3))
- visor.cache("-swap -c=cache")
- }
+ visor.cache("-swap -c=cache")
+ }
- it("should show empty projection error message") {
- visor.cache("-swap -c=wrong")
- }
+ it should "show empty projection error message" in {
+ visor.cache("-swap -c=wrong")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/deploy/VisorDeployCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/deploy/VisorDeployCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/deploy/VisorDeployCommandSpec.scala
index b80ff1d..6003119 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/deploy/VisorDeployCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/deploy/VisorDeployCommandSpec.scala
@@ -25,10 +25,10 @@ import org.apache.ignite.visor.commands.deploy.VisorDeployCommand._
/**
* Unit test for 'deploy' command.
*/
-class VisorDeployCommandSpec extends FunSpec with Matchers {
- describe("A 'deploy' visor command") {
- it("should copy folder") {
- visor.deploy("-h=uname:passwd@localhost -s=/home/uname/test -d=dir")
- }
+class VisorDeployCommandSpec extends FlatSpec with Matchers {
+ behavior of "A 'deploy' visor command"
+
+ it should "copy folder" in {
+ visor.deploy("-h=uname:passwd@localhost -s=/home/uname/test -d=dir")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/disco/VisorDiscoveryCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/disco/VisorDiscoveryCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/disco/VisorDiscoveryCommandSpec.scala
index 335a048..64f0e0f 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/disco/VisorDiscoveryCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/disco/VisorDiscoveryCommandSpec.scala
@@ -51,35 +51,35 @@ class VisorDiscoveryCommandSpec extends VisorRuntimeBaseSpec(4) {
cfg
}
- describe("A 'disco' visor command") {
- it("should advise to connect") {
- closeVisorQuiet()
+ behavior of "A 'disco' visor command"
- visor.disco()
- }
+ it should "advise to connect" in {
+ closeVisorQuiet()
- it("should show all discovery events") {
- visor.disco()
- }
+ visor.disco()
+ }
- it("should show all discovery events in reversed order") {
- visor.disco("-r")
- }
+ it should "show all discovery events" in {
+ visor.disco()
+ }
- it("should show discovery events from last two minutes") {
- visor.disco("-t=2m")
- }
+ it should "show all discovery events in reversed order" in {
+ visor.disco("-r")
+ }
- it("should show discovery events from last two minutes in reversed order ") {
- visor.disco("-t=2m -r")
- }
+ it should "show discovery events from last two minutes" in {
+ visor.disco("-t=2m")
+ }
- it("should show top 3 discovery events") {
- visor.disco("-c=3")
- }
+ it should "show discovery events from last two minutes in reversed order " in {
+ visor.disco("-t=2m -r")
+ }
+
+ it should "show top 3 discovery events" in {
+ visor.disco("-c=3")
+ }
- it("should print error message with invalid count") {
- visor.disco("-c=x")
- }
+ it should "print error message with invalid count" in {
+ visor.disco("-c=x")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/events/VisorEventsCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/events/VisorEventsCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/events/VisorEventsCommandSpec.scala
index 5b18590..365032e 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/events/VisorEventsCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/events/VisorEventsCommandSpec.scala
@@ -40,23 +40,23 @@ class VisorEventsCommandSpec extends VisorRuntimeBaseSpec(1) {
cfg
}
- describe("A 'events' visor command") {
- it("should print error message when not connected") {
- closeVisorQuiet()
+ behavior of "A 'events' visor command"
- visor.events()
- }
+ it should "print error message when not connected" in {
+ closeVisorQuiet()
- it("should display all events from remote node") {
- visor.events("-id8=@n0")
- }
+ visor.events()
+ }
+
+ it should "display all events from remote node" in {
+ visor.events("-id8=@n0")
+ }
- it("should display top 3 events from remote node") {
- visor.events("-id8=@n0 -c=3")
- }
+ it should "display top 3 events from remote node" in {
+ visor.events("-id8=@n0 -c=3")
+ }
- it("should print error message with invalid count") {
- visor.events("-id8=@n0 -c=x")
- }
+ it should "print error message with invalid count" in {
+ visor.events("-id8=@n0 -c=x")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/gc/VisorGcCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/gc/VisorGcCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/gc/VisorGcCommandSpec.scala
index b467687..678aaf4 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/gc/VisorGcCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/gc/VisorGcCommandSpec.scala
@@ -25,14 +25,15 @@ import org.apache.ignite.visor.{VisorRuntimeBaseSpec, visor}
* Unit test for 'gc' command.
*/
class VisorGcCommandSpec extends VisorRuntimeBaseSpec(1) {
+ behavior of "A 'gc' visor command"
+
/**
* Creates grid configuration for provided grid host.
*
* @param name Grid name.
* @return Grid configuration.
*/
- override def config(name: String): IgniteConfiguration =
- {
+ override def config(name: String): IgniteConfiguration = {
val cfg = new IgniteConfiguration
cfg.setGridName(name)
@@ -40,22 +41,19 @@ class VisorGcCommandSpec extends VisorRuntimeBaseSpec(1) {
cfg
}
- describe("'gc' visor command") {
- it("should run GC on all nodes") {
- visor.gc()
- }
-
- it("should run GC on first node") {
- visor.gc("-id8=@n0")
- }
+ it should "run GC on all nodes" in {
+ visor.gc()
+ }
- it("should run GC and DGC on all nodes") {
- visor.gc("-c")
- }
+ it should "run GC on first node" in {
+ visor.gc("-id8=@n0")
+ }
- it("should run GC and DGC on first node") {
- visor.gc("-id8=@n0 -c")
- }
+ it should "run GC and DGC on all nodes" in {
+ visor.gc("-c")
+ }
+ it should "run GC and DGC on first node" in {
+ visor.gc("-id8=@n0 -c")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/help/VisorHelpCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/help/VisorHelpCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/help/VisorHelpCommandSpec.scala
index 43c6f52..b97cb85 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/help/VisorHelpCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/help/VisorHelpCommandSpec.scala
@@ -23,7 +23,7 @@ import org.scalatest._
/**
* Unit test for 'help' command.
*/
-class VisorHelpCommandSpec extends FunSpec with Matchers {
+class VisorHelpCommandSpec extends FlatSpec with Matchers {
// Pre-initialize command so that help can be registered.
commands.ack.VisorAckCommand
commands.ping.VisorPingCommand
@@ -40,34 +40,29 @@ class VisorHelpCommandSpec extends FunSpec with Matchers {
commands.deploy.VisorDeployCommand
commands.start.VisorStartCommand
-
- describe("General help") {
- it ("should properly execute via alias") { visor.searchCmd("?").get.emptyArgs }
- it ("should properly execute w/o alias") { visor.searchCmd("help").get.emptyArgs }
- }
-
- describe("Help for command") {
- it ("should properly execute for 'start' command") { visor.help("start") }
- it ("should properly execute for 'deploy' command") { visor.help("deploy") }
- it ("should properly execute for 'events' command") { visor.help("events") }
- it ("should properly execute for 'mclear' command") { visor.help("mclear") }
- it ("should properly execute for 'cache' command") { visor.help("cache") }
- it ("should properly execute for 'disco' command") { visor.help("disco") }
- it ("should properly execute for 'alert' command") { visor.help("alert") }
- it ("should properly execute for 'node' command") { visor.help("node") }
- it ("should properly execute for 'vvm' command") { visor.help("vvm") }
- it ("should properly execute for 'kill' command") { visor.help("kill") }
- it ("should properly execute for 'top' command") { visor.help("top") }
- it ("should properly execute for 'config' command") { visor.help("config") }
- it ("should properly execute for 'ack' command") { visor.help("ack") }
- it ("should properly execute for 'ping' command") { visor.help("ping") }
- it ("should properly execute for 'close' command") { visor.help("close") }
- it ("should properly execute for 'open' command") { visor.help("open") }
- it ("should properly execute for 'start' status") { visor.help("status") }
- it ("should properly execute for 'start' mset") { visor.help("mset") }
- it ("should properly execute for 'start' mget") { visor.help("mget") }
- it ("should properly execute for 'start' mlist") { visor.help("mlist") }
- it ("should properly execute for 'start' log") { visor.help("log") }
- it ("should properly execute for 'start' dash") { visor.help("dash") }
- }
+ "General help" should "properly execute via alias" in { visor.help() }
+ "General help" should "properly execute w/o alias" in { visor.help() }
+ "Help for 'start' command" should "properly execute" in { visor.help("start") }
+ "Help for 'deploy' command" should "properly execute" in { visor.help("deploy") }
+ "Help for 'events' command" should "properly execute" in { visor.help("events") }
+ "Help for 'mclear' command" should "properly execute" in { visor.help("mclear") }
+ "Help for 'cache' command" should "properly execute" in { visor.help("cache") }
+ "Help for 'disco' command" should "properly execute" in { visor.help("disco") }
+ "Help for 'alert' command" should "properly execute" in { visor.help("alert") }
+ "Help for 'node' command" should "properly execute" in { visor.help("node") }
+ "Help for 'vvm' command" should "properly execute" in { visor.help("vvm") }
+ "Help for 'kill' command" should "properly execute" in { visor.help("kill") }
+ "Help for 'top' command" should "properly execute" in { visor.help("top") }
+ "Help for 'config' command" should "properly execute" in { visor.help("config") }
+ "Help for 'ack' command" should "properly execute" in { visor.help("ack") }
+ "Help for 'ping' command" should "properly execute" in { visor.help("ping") }
+ "Help for 'close' command" should "properly execute" in { visor.help("close") }
+ "Help for 'open' command" should "properly execute" in { visor.help("open") }
+ "Help for 'status' command" should "properly execute" in { visor.help("status") }
+ "Help for 'mset' command" should "properly execute" in { visor.help("mset") }
+ "Help for 'mget' command" should "properly execute" in { visor.help("mget") }
+ "Help for 'mlist' command" should "properly execute" in { visor.help("mlist") }
+ "Help for 'help' command" should "properly execute" in { visor.help("help") }
+ "Help for 'log' command" should "properly execute" in { visor.help("log") }
+ "Help for 'dash' command" should "properly execute" in { visor.help("dash") }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/kill/VisorKillCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/kill/VisorKillCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/kill/VisorKillCommandSpec.scala
index 2c659b5..43ef313 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/kill/VisorKillCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/kill/VisorKillCommandSpec.scala
@@ -25,34 +25,34 @@ import org.apache.ignite.visor.commands.kill.VisorKillCommand._
/**
* Unit test for 'kill' command.
*/
-class VisorKillCommandSpec extends FunSpec with Matchers {
- describe("A 'kill' visor command") {
- it("should print error message with null argument") {
- visor.open("-d")
- visor.kill(null)
- visor.close()
- }
-
- it("should print error message if both kill and restart specified") {
- visor.open("-d")
- visor.kill("-k -r")
- visor.close()
- }
-
- it("should print error message if not connected") {
- visor.kill("-k")
- }
-
- it("should restart node") {
- visor.open("-d")
- visor.kill("-r -id8=@n1")
- visor.close()
- }
-
- it("should print error message") {
- visor.open("-d")
- visor.kill("-r -id=xxx")
- visor.close()
- }
+class VisorKillCommandSpec extends FlatSpec with Matchers {
+ behavior of "A 'kill' visor command"
+
+ it should "print error message with null argument" in {
+ visor.open("-d")
+ visor.kill(null)
+ visor.close()
+ }
+
+ it should "print error message if both kill and restart specified" in {
+ visor.open("-d")
+ visor.kill("-k -r")
+ visor.close()
+ }
+
+ it should "print error message if not connected" in {
+ visor.kill("-k")
+ }
+
+ it should "restart node" in {
+ visor.open("-d")
+ visor.kill("-r -id8=@n1")
+ visor.close()
+ }
+
+ it should "print error message" in {
+ visor.open("-d")
+ visor.kill("-r -id=xxx")
+ visor.close()
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/log/VisorLogCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/log/VisorLogCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/log/VisorLogCommandSpec.scala
index ddb84ea..dcf7aae 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/log/VisorLogCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/log/VisorLogCommandSpec.scala
@@ -23,10 +23,10 @@ import org.scalatest._
/**
* Unit test for 'log' command.
*/
-class VisorLogCommandSpec extends FunSpec with Matchers {
- describe("A 'log' visor command") {
- it("should print log status") {
- visor.log()
- }
+class VisorLogCommandSpec extends FlatSpec with Matchers {
+ behavior of "A 'log' visor command"
+
+ it should "print log status" in {
+ visor.log()
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
index 27eaa94..744d93b 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
@@ -23,60 +23,53 @@ import org.scalatest._
/**
* Unit test for memory commands.
*/
-class VisorMemoryCommandSpec extends FunSpec with Matchers {
- describe("A 'mget' visor command") {
- it("should get correct value") {
- visor.mset("key", "value")
+class VisorMemoryCommandSpec extends FlatSpec with Matchers {
+ "A 'mget' visor command" should "get correct value" in {
+ visor.mset("key", "value")
- assertResult(Option("value"))(visor.mgetOpt("key"))
+ assertResult(Option("value"))(visor.mgetOpt("key"))
- visor.mclear()
- }
+ visor.mclear()
}
- describe("A 'mlist' visor command") {
- it("should list all variables") {
- visor.mset("key1", "value1")
- visor.mset("key2", "value2")
- visor.mset("key3", "value3")
+ "A 'mlist' visor command" should "list all variables" in {
+ visor.mset("key1", "value1")
+ visor.mset("key2", "value2")
+ visor.mset("key3", "value3")
- visor.mlist()
- visor.mclear()
- }
+ visor.mlist()
+ visor.mclear()
+ }
- it("should list ax and cx variables") {
- visor.mset("a1", "1")
- visor.mset("a2", "2")
- visor.mset("b1", "3")
- visor.mset("b2", "4")
- visor.mset("c1", "5")
- visor.mset("c2", "6")
+ "A 'mlist' visor command" should "list ax and cx variables" in {
+ visor.mset("a1", "1")
+ visor.mset("a2", "2")
+ visor.mset("b1", "3")
+ visor.mset("b2", "4")
+ visor.mset("c1", "5")
+ visor.mset("c2", "6")
- visor.mlist("ac")
- visor.mclear()
- }
+ visor.mlist("ac")
+ visor.mclear()
}
- describe("A 'mclear' visor command") {
- it("should remove first two variables") {
- visor.mset("key1", "value1")
- visor.mset("key2", "value2")
- visor.mset("key3", "value3")
-
- visor mclear "key1 key2"
+ "A 'mclear' visor command" should "remove first two variables" in {
+ visor.mset("key1", "value1")
+ visor.mset("key2", "value2")
+ visor.mset("key3", "value3")
- visor.mlist()
- visor.mclear()
+ visor mclear "key1 key2"
- }
+ visor.mlist()
+ visor.mclear()
+ }
- it("should remove all variables") {
- visor.mset("key1", "value1")
- visor.mset("key2", "value2")
- visor.mset("key3", "value3")
+ "A 'mclear' visor command" should "remove all variables" in {
+ visor.mset("key1", "value1")
+ visor.mset("key2", "value2")
+ visor.mset("key3", "value3")
- visor.mclear()
- visor.mlist()
- }
+ visor.mclear()
+ visor.mlist()
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
index c0983c0..992ff7f 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
@@ -24,19 +24,19 @@ import org.apache.ignite.visor.commands.node.VisorNodeCommand._
* Unit test for 'node' command.
*/
class VisorNodeCommandSpec extends VisorRuntimeBaseSpec(1) {
- describe("A 'node' visor command") {
- it("should properly execute with valid node ID") {
- visor.node("-id8=@n1")
- }
+ behavior of "A 'node' visor command"
- it("should print the error message for invalid node ID") {
- visor.node("-id8=zeee")
- }
+ it should "properly execute with valid node ID" in {
+ visor.node("-id8=@n1")
+ }
+
+ it should "print the error message for invalid node ID" in {
+ visor.node("-id8=zeee")
+ }
- it("should print error message when not connected") {
- closeVisorQuiet()
+ it should "print error message when not connected" in {
+ closeVisorQuiet()
- visor.node("") // Arguments are ignored.
- }
+ visor.node("") // Arguments are ignored.
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/open/VisorOpenCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/open/VisorOpenCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/open/VisorOpenCommandSpec.scala
index 4cf2204..786d04e 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/open/VisorOpenCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/open/VisorOpenCommandSpec.scala
@@ -24,15 +24,15 @@ import org.apache.ignite.visor.{VisorRuntimeBaseSpec, visor}
* Unit test for 'open' command.
*/
class VisorOpenCommandSpec extends VisorRuntimeBaseSpec(3) {
- describe("A 'open' visor command") {
- it("should properly connect using default configuration") {
- visor.mlist()
- }
+ behavior of "A 'open' visor command"
+
+ it should "properly connect using default configuration" in {
+ visor.mlist()
+ }
- it("should print error message when already connected") {
- intercept[IgniteException] {
- openVisor()
- }
+ it should "print error message when already connected" in {
+ intercept[IgniteException] {
+ openVisor()
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/ping/VisorPingCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/ping/VisorPingCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/ping/VisorPingCommandSpec.scala
index 06e3a22..dde5f18 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/ping/VisorPingCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/ping/VisorPingCommandSpec.scala
@@ -24,15 +24,15 @@ import org.apache.ignite.visor.commands.ping.VisorPingCommand._
* Unit test for 'ping' command.
*/
class VisorPingCommandSpec extends VisorRuntimeBaseSpec(2) {
- describe("A 'ping' visor command") {
- it("should properly execute") {
- visor.ping()
- }
+ behavior of "A 'ping' visor command"
- it("should print error message when not connected") {
- closeVisorQuiet()
+ it should "properly execute" in {
+ visor.ping()
+ }
+
+ it should "print error message when not connected" in {
+ closeVisorQuiet()
- visor.ping()
- }
+ visor.ping()
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/start/VisorStartCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/start/VisorStartCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/start/VisorStartCommandSpec.scala
index c6404b5..1a451c4 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/start/VisorStartCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/start/VisorStartCommandSpec.scala
@@ -26,7 +26,7 @@ import org.apache.ignite.visor.commands.top.VisorTopologyCommand._
/**
* Unit test for 'start' command.
*/
-class VisorStartCommandSpec extends FunSpec with Matchers with BeforeAndAfterAll {
+class VisorStartCommandSpec extends FlatSpec with Matchers with BeforeAndAfterAll {
override def beforeAll() {
visor.open("-d")
}
@@ -35,89 +35,89 @@ class VisorStartCommandSpec extends FunSpec with Matchers with BeforeAndAfterAll
visor.close()
}
- describe("A 'start' visor command") {
- it("should should start one new node") {
- visor.start("-h=192.168.1.103 -r -p=password")
- }
+ behavior of "A 'start' visor command"
- it("should should start two nodes") {
- visor.start("-h=uname:passwd@localhost -n=2")
- }
+ it should "should start one new node" in {
+ visor.start("-h=192.168.1.103 -r -p=password")
+ }
- it("should print error message with invalid port number") {
- visor.start("-h=localhost:x -p=passwd")
- }
+ it should "should start two nodes" in {
+ visor.start("-h=uname:passwd@localhost -n=2")
+ }
- it("should print error message with zero port number") {
- visor.start("-h=localhost:0 -p=passwd")
- }
+ it should "print error message with invalid port number" in {
+ visor.start("-h=localhost:x -p=passwd")
+ }
- it("should print error message with negative port number") {
- visor.start("-h=localhost:-1 -p=passwd")
- }
+ it should "print error message with zero port number" in {
+ visor.start("-h=localhost:0 -p=passwd")
+ }
- it("should print error message with invalid nodes count") {
- visor.start("-h=localhost#x -p=passwd")
- }
+ it should "print error message with negative port number" in {
+ visor.start("-h=localhost:-1 -p=passwd")
+ }
- it("should print error message with zero nodes count") {
- visor.start("-h=localhost#0 -p=passwd")
- }
+ it should "print error message with invalid nodes count" in {
+ visor.start("-h=localhost#x -p=passwd")
+ }
- it("should print error message with negative nodes count") {
- visor.start("-h=localhost#-1 -p=passwd")
- }
+ it should "print error message with zero nodes count" in {
+ visor.start("-h=localhost#0 -p=passwd")
+ }
- it("should print error message with incorrect host") {
- visor.start("-h=incorrect -p=passwd")
- }
+ it should "print error message with negative nodes count" in {
+ visor.start("-h=localhost#-1 -p=passwd")
+ }
- it("should print error message with incorrect username") {
- visor.start("-h=incorrect@localhost -p=passwd")
- }
+ it should "print error message with incorrect host" in {
+ visor.start("-h=incorrect -p=passwd")
+ }
- it("should print error message with incorrect password") {
- visor.start("-h=uname:incorrect@localhost")
- }
+ it should "print error message with incorrect username" in {
+ visor.start("-h=incorrect@localhost -p=passwd")
+ }
- it("should print error message with nonexistent script path") {
- visor.start("-h=uname:passwd@localhost -s=incorrect")
- }
+ it should "print error message with incorrect password" in {
+ visor.start("-h=uname:incorrect@localhost")
+ }
- it("should print error message with incorrect script path") {
- visor.start("-h=uname:passwd@localhost -s=bin/readme.txt")
- }
+ it should "print error message with nonexistent script path" in {
+ visor.start("-h=uname:passwd@localhost -s=incorrect")
+ }
- it("should print error message with nonexistent config path") {
- visor.start("-h=uname:passwd@localhost -c=incorrect")
- }
+ it should "print error message with incorrect script path" in {
+ visor.start("-h=uname:passwd@localhost -s=bin/readme.txt")
+ }
- it("should print error message with incorrect config path") {
- visor.start("-h=uname:passwd@localhost -c=bin/readme.txt")
- }
+ it should "print error message with nonexistent config path" in {
+ visor.start("-h=uname:passwd@localhost -c=incorrect")
+ }
- it("should start one node") {
- visor.start("-h=uname:passwd@localhost")
+ it should "print error message with incorrect config path" in {
+ visor.start("-h=uname:passwd@localhost -c=bin/readme.txt")
+ }
- visor.top()
- }
+ it should "start one node" in {
+ visor.start("-h=uname:passwd@localhost")
- it("should start one node on host identified by IP") {
- visor.start("-h=uname:passwd@127.0.0.1")
+ visor.top()
+ }
+
+ it should "start one node on host identified by IP" in {
+ visor.start("-h=uname:passwd@127.0.0.1")
- visor.top()
- }
+ visor.top()
+ }
- it("should start two nodes") {
- visor.start("-h=uname:passwd@localhost#2")
+ it should "start two nodes" in {
+ visor.start("-h=uname:passwd@localhost#2")
- visor.top()
- }
+ visor.top()
+ }
- it("should restart 4 nodes") {
- visor.start("-h=uname:passwd@localhost#4 -r")
+ it should "restart 4 nodes" in {
+ visor.start("-h=uname:passwd@localhost#4 -r")
- visor.top()
- }
+ visor.top()
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala
index db07543..320a6bb 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala
@@ -34,7 +34,7 @@ import scala.collection._
/**
* Unit test for 'tasks' command.
*/
-class VisorTasksCommandSpec extends FunSpec with Matchers with BeforeAndAfterAll {
+class VisorTasksCommandSpec extends FlatSpec with Matchers with BeforeAndAfterAll {
/**
* Open visor and execute several tasks before all tests.
*/
@@ -103,78 +103,78 @@ class VisorTasksCommandSpec extends FunSpec with Matchers with BeforeAndAfterAll
Ignition.stopAll(false)
}
- describe("A 'tasks' visor command") {
- it("should print tasks when called w/o arguments") {
- visor.tasks()
- }
+ behavior of "A 'tasks' visor command"
- it("should print error message with incorrect argument") {
- visor.tasks("-xx")
- }
+ it should "print tasks when called w/o arguments" in {
+ visor.tasks()
+ }
- it("should print task summary when called for specific task") {
- visor.tasks("-n=@t1")
- }
+ it should "print error message with incorrect argument" in {
+ visor.tasks("-xx")
+ }
- it("should print execution when called for specific execution") {
- visor.tasks("-e=@e1")
- }
+ it should "print task summary when called for specific task" in {
+ visor.tasks("-n=@t1")
+ }
- it("should print all tasks") {
- visor.tasks("-l")
- }
+ it should "print execution when called for specific execution" in {
+ visor.tasks("-e=@e1")
+ }
- it("should print all tasks and executions") {
- visor.tasks("-l -a")
- }
+ it should "print all tasks" in {
+ visor.tasks("-l")
+ }
- it("should print tasks that started during last 5 seconds") {
- visor.tasks("-l -t=5s")
- }
+ it should "print all tasks and executions" in {
+ visor.tasks("-l -a")
+ }
- it("should print error message about invalid time period") {
- visor.tasks("-l -t=x2s")
- }
+ it should "print tasks that started during last 5 seconds" in {
+ visor.tasks("-l -t=5s")
+ }
- it("should print error message about negative time period") {
- visor.tasks("-l -t=-10s")
- }
+ it should "print error message about invalid time period" in {
+ visor.tasks("-l -t=x2s")
+ }
- it("should print error message about invalid time period specification") {
- visor.tasks("-l -t=10x")
- }
+ it should "print error message about negative time period" in {
+ visor.tasks("-l -t=-10s")
+ }
- it("should print task summary for the first task") {
- visor.tasks("-n=TestTask1")
- }
+ it should "print error message about invalid time period specification" in {
+ visor.tasks("-l -t=10x")
+ }
- it("should print task summary and executions for the first task") {
- visor.tasks("-n=TestTask1 -a")
- }
+ it should "print task summary for the first task" in {
+ visor.tasks("-n=TestTask1")
+ }
- it("should print list of tasks grouped by nodes") {
- visor.tasks("-g")
- }
+ it should "print task summary and executions for the first task" in {
+ visor.tasks("-n=TestTask1 -a")
+ }
- it("should print list of tasks that started during last 5 minutes grouped by nodes") {
- visor.tasks("-g -t=5m")
- }
+ it should "print list of tasks grouped by nodes" in {
+ visor.tasks("-g")
+ }
- it("should print list of tasks grouped by hosts") {
- visor.tasks("-h")
- }
+ it should "print list of tasks that started during last 5 minutes grouped by nodes" in {
+ visor.tasks("-g -t=5m")
+ }
- it("should print list of tasks that started during last 5 minutes grouped by hosts") {
- visor.tasks("-h -t=5m")
- }
+ it should "print list of tasks grouped by hosts" in {
+ visor.tasks("-h")
+ }
- it("should print list of tasks filtered by substring") {
- visor.tasks("-s=TestTask")
- }
+ it should "print list of tasks that started during last 5 minutes grouped by hosts" in {
+ visor.tasks("-h -t=5m")
+ }
- it("should print list of tasks and executions filtered by substring") {
- visor.tasks("-s=TestTask -a")
- }
+ it should "print list of tasks filtered by substring" in {
+ visor.tasks("-s=TestTask")
+ }
+
+ it should "print list of tasks and executions filtered by substring" in {
+ visor.tasks("-s=TestTask -a")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/top/VisorTopologyCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/top/VisorTopologyCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/top/VisorTopologyCommandSpec.scala
index 515cf67..3a3b6e5 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/top/VisorTopologyCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/top/VisorTopologyCommandSpec.scala
@@ -24,39 +24,39 @@ import org.apache.ignite.visor.commands.top.VisorTopologyCommand._
* Unit test for topology commands.
*/
class VisorTopologyCommandSpec extends VisorRuntimeBaseSpec(2) {
- describe("A 'top' visor command") {
- it("should advise to connect") {
- closeVisorQuiet()
+ behavior of "A 'top' visor command"
- visor.top()
- }
+ it should "advise to connect" in {
+ closeVisorQuiet()
- it("should print error message") {
- visor.top("-cc=eq1x")
- }
+ visor.top()
+ }
+
+ it should "print error message" in {
+ visor.top("-cc=eq1x")
+ }
- it("should print full topology") {
- visor.top()
- }
+ it should "print full topology" in {
+ visor.top()
+ }
- it("should print nodes with idle time greater than 12000ms") {
- visor.top("-it=gt12000")
- }
+ it should "print nodes with idle time greater than 12000ms" in {
+ visor.top("-it=gt12000")
+ }
- it("should print nodes with idle time greater than 12sec") {
- visor.top("-it=gt12s")
- }
+ it should "print nodes with idle time greater than 12sec" in {
+ visor.top("-it=gt12s")
+ }
- it("should print full information about all nodes") {
- visor.top("-a")
- }
+ it should "print full information about all nodes" in {
+ visor.top("-a")
+ }
- it("should print information about nodes on localhost") {
- visor.top("-h=192.168.1.100")
- }
+ it should "print information about nodes on localhost" in {
+ visor.top("-h=192.168.1.100")
+ }
- it("should print full information about nodes on localhost") {
- visor.top("-h=localhost")
- }
+ it should "print full information about nodes on localhost" in {
+ visor.top("-h=localhost")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/vvm/VisorVvmCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/vvm/VisorVvmCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/vvm/VisorVvmCommandSpec.scala
index 1a4bc3e..969fb94 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/vvm/VisorVvmCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/vvm/VisorVvmCommandSpec.scala
@@ -25,22 +25,22 @@ import org.apache.ignite.visor.commands.vvm.VisorVvmCommand._
/**
* Unit test for 'vvm' command.
*/
-class VisorVvmCommandSpec extends FunSpec with Matchers {
- describe("A 'vvm' visor command") {
- it("should print error message when not connected") {
- visor.vvm()
- }
+class VisorVvmCommandSpec extends FlatSpec with Matchers {
+ behavior of "A 'vvm' visor command"
- it("should open VisualVM connected to all nodes skipping ones with disabled JMX") {
- visor.open("-d")
- visor.vvm()
- visor.close()
- }
+ it should "print error message when not connected" in {
+ visor.vvm()
+ }
+
+ it should "open VisualVM connected to all nodes skipping ones with disabled JMX" in {
+ visor.open("-d")
+ visor.vvm()
+ visor.close()
+ }
- it("should open VisualVM connected to first node if it has JMX enabled") {
- visor.open("-d")
- visor.vvm("-id8=@n1")
- visor.close()
- }
+ it should "open VisualVM connected to first node if it has JMX enabled" in {
+ visor.open("-d")
+ visor.vvm("-id8=@n1")
+ visor.close()
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index cd098d9..661b310 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -619,7 +619,6 @@
<exclude>**/keystore/*.pfx</exclude><!--bin-files-->
<!--special excludes-->
<exclude>DEVNOTES.txt</exclude>
- <exclude>DEPENDENCIES</exclude><!--automatically generated file. presents at source pack-->
<exclude>src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridOffHeapSnapTreeMap.java</exclude><!--BSD license-->
<exclude>src/main/java/org/apache/ignite/internal/util/snaptree/*.java</exclude><!--BSD license-->
<exclude>src/main/java/org/jsr166/*.java</exclude>
@@ -629,7 +628,6 @@
<exclude>src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.empty</exclude><!--should be empty-->
<exclude>src/test/java/org/apache/ignite/spi/deployment/uri/META-INF/ignite.brokenxml</exclude><!--test resource-->
<exclude>src/test/java/org/apache/ignite/internal/processors/hadoop/books/*.txt</exclude><!--books examples-->
- <exclude>src/main/java/org/apache/ignite/examples/streaming/wordcount/*.txt</exclude><!--books examples-->
<exclude>examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/*.txt</exclude><!--books examples-->
<exclude>src/main/java/META-INF/services/javax.cache.spi.CachingProvider</exclude><!--cannot be changed-->
<exclude>src/main/java/org/jetbrains/annotations/*.java</exclude><!--copyright-->
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8886c8a..c5a9e5d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -36,6 +36,8 @@
<packaging>pom</packaging>
<properties>
+ <ignite.site>scp://localhost:/home</ignite.site>
+ <ignite.site.folder>${project.artifactId}-${project.version}</ignite.site.folder>
<!--fix <attachartifact>...< /> at apache-release profile if changed-->
<ignite.zip.pattern>ignite-${ignite.edition}-${project.version}</ignite.zip.pattern>
</properties>
@@ -47,6 +49,13 @@
<tag>HEAD</tag>
</scm>
+ <distributionManagement>
+ <site>
+ <id>ignite-site</id>
+ <url>${ignite.site}/${ignite.site.folder}</url>
+ </site>
+ </distributionManagement>
+
<modules>
<module>modules/tools</module>
<module>modules/core</module>
@@ -113,6 +122,26 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>clean</phase>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>libs</directory>
+ </fileset>
+ </filesets>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<inherited>false</inherited>
@@ -246,7 +275,7 @@
</replaceregexp>
<replaceregexp byline="true">
- <regexp pattern="\. "\$\{SCRIPTS_HOME\}"/include/build-classpath.sh(\s*#.*)?" />
+ <regexp pattern="\. "\$\{SCRIPTS_HOME\}"/include/target-classpath.sh(\s*#.*)?" />
<substitution expression="" />
<fileset dir="${basedir}/target/release-package/bin">
<include name="**/*.sh" />
@@ -254,7 +283,7 @@
</replaceregexp>
<replaceregexp byline="true">
- <regexp pattern="call "%SCRIPTS_HOME%\\include\\build-classpath.bat"(\s*&::.*)?" />
+ <regexp pattern="call "%SCRIPTS_HOME%\\include\\target-classpath.bat"(\s*&::.*)?" />
<substitution expression="" />
<fileset dir="${basedir}/target/release-package/bin">
<include name="**/*.bat" />
@@ -291,8 +320,6 @@
<substitution expression="${project.version}" />
</replaceregexp>
- <chmod dir="${basedir}/target/release-package" perm="755" includes="**/*.sh"/>
-
<zip destfile="${basedir}/target/bin/${ignite.zip.pattern}.zip" encoding="UTF-8">
<zipfileset dir="${basedir}/target/release-package" prefix="${ignite.zip.pattern}" filemode="755">
<include name="**/*.sh" />
@@ -566,12 +593,36 @@
<include name="**/*" />
</fileset>
</copy>
- <copy file="${basedir}/KEYS" todir="${basedir}/target/site" failonerror="false"/>
+ <copy file="${basedir}/KEYS" todir="${basedir}/target/site" />
</target>
</configuration>
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.4</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh</artifactId>
+ <version>2.8</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <goals>
+ <goal>deploy</goal>
+ </goals>
+ <phase>deploy</phase>
+ <configuration>
+ <inputDirectory>${basedir}/target/site</inputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</profile>
@@ -689,28 +740,4 @@
</build>
</profile>
</profiles>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-clean-plugin</artifactId>
- <executions>
- <execution>
- <phase>clean</phase>
- <goals>
- <goal>clean</goal>
- </goals>
- <configuration>
- <filesets>
- <fileset>
- <directory>libs</directory>
- </fileset>
- </filesets>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
</project>
[2/8] incubator-ignite git commit: Revert "ignite-471: fixed NPE in
PortableMarshaller"
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
index 6192f39..5072642 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.cache.distributed.near;
import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
import org.apache.ignite.cache.affinity.rendezvous.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.*;
@@ -34,8 +35,6 @@ import org.apache.ignite.transactions.*;
import java.util.*;
import static org.apache.ignite.IgniteSystemProperties.*;
-import static org.apache.ignite.cache.CacheMode.*;
-import static org.apache.ignite.cache.CacheRebalanceMode.*;
import static org.apache.ignite.transactions.TransactionConcurrency.*;
import static org.apache.ignite.transactions.TransactionIsolation.*;
@@ -77,10 +76,10 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
CacheConfiguration cc = defaultCacheConfiguration();
- cc.setCacheMode(PARTITIONED);
+ cc.setCacheMode(CacheMode.PARTITIONED);
cc.setAffinity(new RendezvousAffinityFunction(false, 18));
cc.setBackups(1);
- cc.setRebalanceMode(SYNC);
+ cc.setRebalanceMode(CacheRebalanceMode.SYNC);
c.setCacheConfiguration(cc);
@@ -110,9 +109,8 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
+ // Shutwodn the gird.
stopAllGrids();
-
- System.gc();
}
/**
@@ -147,8 +145,8 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
* Check whether caches has no transactions after salvage timeout.
*
* @param mode Transaction mode (PESSIMISTIC, OPTIMISTIC).
- * @param prepare Whether to prepare transaction state
- * (i.e. call {@link IgniteInternalTx#prepare()}).
+ * @param prepare Whether to preapre transaction state
+ * (i.e. call {@link org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx#prepare()}).
* @throws Exception If failed.
*/
private void checkSalvageAfterTimeout(TransactionConcurrency mode, boolean prepare) throws Exception {
@@ -166,8 +164,8 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
* Check whether caches still has all transactions before salvage timeout.
*
* @param mode Transaction mode (PESSIMISTIC, OPTIMISTIC).
- * @param prepare Whether to prepare transaction state
- * (i.e. call {@link IgniteInternalTx#prepare()}).
+ * @param prepare Whether to preapre transaction state
+ * (i.e. call {@link org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx#prepare()}).
* @throws Exception If failed.
*/
private void checkSalvageBeforeTimeout(TransactionConcurrency mode, boolean prepare) throws Exception {
@@ -193,8 +191,8 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
* Start new transaction on the grid(0) and put some keys to it.
*
* @param mode Transaction mode (PESSIMISTIC, OPTIMISTIC).
- * @param prepare Whether to prepare transaction state
- * (i.e. call {@link IgniteInternalTx#prepare()}).
+ * @param prepare Whether to preapre transaction state
+ * (i.e. call {@link org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx#prepare()}).
* @throws Exception If failed.
*/
private void startTxAndPutKeys(final TransactionConcurrency mode, final boolean prepare) throws Exception {
@@ -212,8 +210,9 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
for (Integer key : keys)
c.put(key, "val" + key);
+ // Unproxy.
if (prepare)
- ((TransactionProxyImpl)tx).tx().prepare();
+ U.<IgniteInternalTx>field(tx, "tx").prepare();
}
catch (IgniteCheckedException e) {
info("Failed to put keys to cache: " + e.getMessage());
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NoneRebalanceModeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NoneRebalanceModeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NoneRebalanceModeSelfTest.java
deleted file mode 100644
index d61ddcc..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NoneRebalanceModeSelfTest.java
+++ /dev/null
@@ -1,67 +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.internal.processors.cache.distributed.near;
-
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.cache.distributed.dht.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import static org.apache.ignite.cache.CacheRebalanceMode.*;
-import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.*;
-
-/**
- * Test none rebalance mode.
- */
-public class NoneRebalanceModeSelfTest extends GridCommonAbstractTest {
- /** {@inheritDoc} */
- @SuppressWarnings({"ConstantConditions"})
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration c = super.getConfiguration(gridName);
-
- CacheConfiguration cc = defaultCacheConfiguration();
-
- cc.setRebalanceMode(NONE);
-
- c.setCacheConfiguration(cc);
-
- return c;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- startGrid(0);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testRemoveAll() throws Exception {
- GridNearTransactionalCache cache = (GridNearTransactionalCache)((IgniteKernal)grid(0)).internalCache(null);
-
- for (GridDhtLocalPartition part : cache.dht().topology().localPartitions())
- assertEquals(MOVING, part.state());
-
- grid(0).cache(null).removeAll();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFailoverSelfTest.java
index 3461dd4..326f57d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFailoverSelfTest.java
@@ -18,7 +18,6 @@
package org.apache.ignite.internal.processors.cache.distributed.replicated;
import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.processors.cache.*;
import static org.apache.ignite.cache.CacheMode.*;
@@ -31,9 +30,4 @@ public class GridCacheReplicatedFailoverSelfTest extends GridCacheAbstractFailov
@Override protected CacheMode cacheMode() {
return REPLICATED;
}
-
- /** {@inheritDoc} */
- @Override protected NearCacheConfiguration nearConfiguration() {
- return null;
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedLockSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedLockSelfTest.java
index 510fa0c..97df1f0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedLockSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedLockSelfTest.java
@@ -30,9 +30,4 @@ public class GridCacheReplicatedLockSelfTest extends GridCacheLockAbstractTest {
@Override protected CacheMode cacheMode() {
return REPLICATED;
}
-
- /** {@inheritDoc} */
- @Override public void testLockReentrancy() throws Throwable {
- fail("https://issues.apache.org/jira/browse/IGNITE-835");
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedNodeRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedNodeRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedNodeRestartSelfTest.java
index 8ce96cd..0023160 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedNodeRestartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedNodeRestartSelfTest.java
@@ -54,84 +54,4 @@ public class GridCacheReplicatedNodeRestartSelfTest extends GridCacheAbstractNod
return c;
}
-
- /** {@inheritDoc} */
- @Override public void testRestartWithPutTwoNodesNoBackups() throws Throwable {
- super.testRestartWithPutTwoNodesNoBackups();
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithPutTwoNodesOneBackup() throws Throwable {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithPutFourNodesOneBackups() throws Throwable {
- super.testRestartWithPutFourNodesOneBackups();
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithPutFourNodesNoBackups() throws Throwable {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithPutSixNodesTwoBackups() throws Throwable {
- super.testRestartWithPutSixNodesTwoBackups();
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithPutEightNodesTwoBackups() throws Throwable {
- super.testRestartWithPutEightNodesTwoBackups();
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithPutTenNodesTwoBackups() throws Throwable {
- super.testRestartWithPutTenNodesTwoBackups();
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithTxTwoNodesNoBackups() throws Throwable {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithTxTwoNodesOneBackup() throws Throwable {
- super.testRestartWithTxTwoNodesOneBackup();
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithTxFourNodesOneBackups() throws Throwable {
- super.testRestartWithTxFourNodesOneBackups();
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithTxFourNodesNoBackups() throws Throwable {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithTxSixNodesTwoBackups() throws Throwable {
- super.testRestartWithTxSixNodesTwoBackups();
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithTxEightNodesTwoBackups() throws Throwable {
- super.testRestartWithTxEightNodesTwoBackups();
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithTxTenNodesTwoBackups() throws Throwable {
- super.testRestartWithTxTenNodesTwoBackups();
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithTxPutAllTenNodesTwoBackups() throws Throwable {
- super.testRestartWithTxPutAllTenNodesTwoBackups();
- }
-
- /** {@inheritDoc} */
- @Override public void testRestartWithTxPutAllFourNodesTwoBackups() throws Throwable {
- super.testRestartWithTxPutAllFourNodesTwoBackups();
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java
index ee42ddb..dbfdc86 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java
@@ -40,7 +40,7 @@ public class GridCacheLocalIsolatedNodesSelfTest extends GridCommonAbstractTest
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
- startGrids(3);
+ startGrids(2);
}
/** {@inheritDoc} */
@@ -59,11 +59,7 @@ public class GridCacheLocalIsolatedNodesSelfTest extends GridCommonAbstractTest
Ignite g2 = grid(1);
UUID nid2 = g2.cluster().localNode().id();
- Ignite g3 = grid(2);
- UUID nid3 = g3.cluster().localNode().id();
-
assert !nid1.equals(nid2);
- assert !nid1.equals(nid3);
// Local cache on first node only.
CacheConfiguration<String, String> ccfg1 = new CacheConfiguration<>("A");
@@ -81,20 +77,8 @@ public class GridCacheLocalIsolatedNodesSelfTest extends GridCommonAbstractTest
IgniteCache<String, String> c2 = g2.createCache(ccfg2);
c2.put("g2", "c2");
- // Local cache on third node only.
- CacheConfiguration<String, String> ccfg3 = new CacheConfiguration<>("A");
- ccfg3.setCacheMode(LOCAL);
- ccfg3.setNodeFilter(new NodeIdFilter(nid3));
-
- IgniteCache<String, String> c3 = g3.createCache(ccfg3);
- c3.put("g3", "c3");
-
assertNull(c1.get("g2"));
- assertNull(c1.get("g3"));
assertNull(c2.get("g1"));
- assertNull(c2.get("g3"));
- assertNull(c3.get("g1"));
- assertNull(c3.get("g2"));
}
/** Filter by node ID. */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBufferTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBufferTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBufferTest.java
deleted file mode 100644
index a0dd2e5..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBufferTest.java
+++ /dev/null
@@ -1,112 +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.internal.util.nio;
-
-import junit.framework.TestCase;
-
-import java.nio.*;
-import java.util.*;
-
-/**
- * Tests for {@link GridNioDelimitedBuffer}.
- */
-public class GridNioDelimitedBufferTest extends TestCase {
- /** */
- private static final String ASCII = "ASCII";
-
- /**
- * Tests simple delimiter (excluded from alphabet)
- */
- public void testReadZString() throws Exception {
- Random rnd = new Random();
-
- int buffSize = 0;
-
- byte[] delim = new byte[] {0};
-
- List<String> strs = new ArrayList<>(50);
-
- for (int i = 0; i < 50; i++) {
- int len = rnd.nextInt(128) + 1;
-
- buffSize += len + delim.length;
-
- StringBuilder sb = new StringBuilder(len);
-
- for (int j = 0; j < len; j++)
- sb.append((char)(rnd.nextInt(26) + 'a'));
-
-
- strs.add(sb.toString());
- }
-
- ByteBuffer buff = ByteBuffer.allocate(buffSize);
-
- for (String str : strs) {
- buff.put(str.getBytes(ASCII));
- buff.put(delim);
- }
-
- buff.flip();
-
- byte[] msg;
-
- GridNioDelimitedBuffer delimBuff = new GridNioDelimitedBuffer(delim);
-
- List<String> res = new ArrayList<>(strs.size());
-
- while ((msg = delimBuff.read(buff)) != null)
- res.add(new String(msg, ASCII));
-
- assertEquals(strs, res);
- }
-
- /**
- * Tests compound delimiter (included to alphabet)
- */
- public void testDelim() throws Exception {
- byte[] delim = "aabb".getBytes(ASCII);
-
- List<String> strs = Arrays.asList("za", "zaa", "zaab", "zab", "zaabaababbbbabaab");
-
- int buffSize = 0;
-
- for (String str : strs)
- buffSize += str.length() + delim.length;
-
- ByteBuffer buff = ByteBuffer.allocate(buffSize);
-
- for (String str : strs) {
- buff.put(str.getBytes(ASCII));
- buff.put(delim);
- }
-
- buff.flip();
-
- byte[] msg;
-
- GridNioDelimitedBuffer delimBuff = new GridNioDelimitedBuffer(delim);
-
- List<String> res = new ArrayList<>(strs.size());
-
- while ((msg = delimBuff.read(buff)) != null)
- res.add(new String(msg, ASCII));
-
- assertEquals(strs, res);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryRestartTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryRestartTest.java
deleted file mode 100644
index e6bee4a..0000000
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryRestartTest.java
+++ /dev/null
@@ -1,199 +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.spi.discovery.tcp;
-
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.events.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.testframework.*;
-import org.apache.ignite.testframework.junits.common.*;
-import org.eclipse.jetty.util.*;
-
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-import static org.apache.ignite.events.EventType.*;
-
-/**
- *
- */
-public class TcpDiscoveryRestartTest extends GridCommonAbstractTest {
- /** */
- private TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
- /** */
- private static AtomicReference<String> err;
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- TcpDiscoverySpi spi = new TcpDiscoverySpi();
-
- spi.setIpFinder(ipFinder);
-
- cfg.setDiscoverySpi(spi);
-
- int[] evts = {EVT_NODE_JOINED, EVT_NODE_FAILED, EVT_NODE_LEFT};
-
- cfg.setIncludeEventTypes(evts);
-
- Map<IgnitePredicate<? extends Event>, int[]> lsnrs = new HashMap<>();
-
- lsnrs.put(new TestEventListener(), evts);
-
- cfg.setLocalEventListeners(lsnrs);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- stopAllGrids();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testRestart() throws Exception {
- err = new AtomicReference<>();
-
- final int NODE_CNT = 3;
-
- startGrids(NODE_CNT);
-
- final ConcurrentHashSet<UUID> nodeIds = new ConcurrentHashSet<>();
-
- final AtomicInteger id = new AtomicInteger(NODE_CNT);
-
- final IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
- @Override public Void call() throws Exception {
- int nodeIdx = id.getAndIncrement();
-
- for (int i = 0; i < 10 && err.get() == null; i++) {
- Ignite ignite = startGrid(nodeIdx);
-
- UUID nodeId = ignite.cluster().localNode().id();
-
- if (!nodeIds.add(nodeId))
- failed("Duplicated node ID: " + nodeId);
-
- stopGrid(nodeIdx);
- }
-
- return null;
- }
- }, 5, "restart-thread");
-
- IgniteInternalFuture<?> loadFut = GridTestUtils.runMultiThreadedAsync(new Callable<Long>() {
- @Override public Long call() throws Exception {
- long dummyRes = 0;
-
- List<String> list = new ArrayList<>();
-
- while (!fut.isDone()) {
- for (int i = 0; i < 100; i++) {
- String str = new String(new byte[i]);
-
- list.add(str);
-
- dummyRes += str.hashCode();
- }
-
- if (list.size() > 1000_000) {
- list = new ArrayList<>();
-
- System.gc();
- }
- }
-
- return dummyRes;
- }
- }, 2, "test-load");
-
- fut.get();
-
- loadFut.get();
-
- assertNull(err.get());
-
- for (int i = 0; i < NODE_CNT; i++) {
- Ignite ignite = ignite(i);
-
- TestEventListener lsnr = (TestEventListener)F.firstKey(ignite.configuration().getLocalEventListeners());
-
- assertNotNull(lsnr);
-
- for (UUID nodeId : nodeIds)
- lsnr.checkEvents(nodeId);
- }
- }
-
-
- /**
- * @param msg Message.
- */
- private void failed(String msg) {
- info(msg);
-
- err.compareAndSet(null, msg);
- }
-
- /**
- *
- */
- private class TestEventListener implements IgnitePredicate<Event> {
- /** */
- private final ConcurrentHashSet<UUID> joinIds = new ConcurrentHashSet<>();
-
- /** */
- private final ConcurrentHashSet<UUID> leftIds = new ConcurrentHashSet<>();
-
- /** {@inheritDoc} */
- @Override public boolean apply(Event evt) {
- DiscoveryEvent evt0 = (DiscoveryEvent)evt;
-
- if (evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT) {
- if (!leftIds.add(evt0.eventNode().id()))
- failed("Duplicated failed node ID: " + evt0.eventNode().id());
- }
- else {
- assertEquals(EVT_NODE_JOINED, evt.type());
-
- if (!joinIds.add(evt0.eventNode().id()))
- failed("Duplicated joined node ID: " + evt0.eventNode().id());
- }
-
- return true;
- }
-
- /**
- * @param nodeId Node ID.
- */
- void checkEvents(UUID nodeId) {
- assertTrue("No join event: " + nodeId, joinIds.contains(nodeId));
-
- assertTrue("No left event: " + nodeId, leftIds.contains(nodeId));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java
deleted file mode 100644
index b4a6923..0000000
--- a/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java
+++ /dev/null
@@ -1,316 +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.stream.socket;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.events.*;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.marshaller.*;
-import org.apache.ignite.marshaller.jdk.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.stream.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import org.jetbrains.annotations.*;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-import static org.apache.ignite.events.EventType.*;
-
-/**
- * Tests {@link SocketStreamer}.
- */
-public class SocketStreamerSelfTest extends GridCommonAbstractTest {
- /** IP finder. */
- private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
- /** Grid count. */
- private final static int GRID_CNT = 3;
-
- /** Count. */
- private static final int CNT = 500;
-
- /** Delimiter. */
- private static final byte[] DELIM = new byte[] {0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0};
-
- /** Port. */
- private static int port;
-
- /** Ignite. */
- private static Ignite ignite;
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration() throws Exception {
- IgniteConfiguration cfg = super.getConfiguration();
-
- CacheConfiguration ccfg = cacheConfiguration(cfg, null);
-
- cfg.setCacheConfiguration(ccfg);
-
- TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
- discoSpi.setIpFinder(IP_FINDER);
-
- cfg.setDiscoverySpi(discoSpi);
-
- return cfg;
- }
-
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- ignite = startGrids(GRID_CNT);
- ignite.<Integer, String>getOrCreateCache(defaultCacheConfiguration());
-
- try (ServerSocket sock = new ServerSocket(0)) {
- port = sock.getLocalPort();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- ignite.cache(null).clear();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSizeBasedDefaultConverter() throws Exception {
- test(null, null, new Runnable() {
- @Override public void run() {
- try (Socket sock = new Socket(InetAddress.getLocalHost(), port);
- OutputStream os = new BufferedOutputStream(sock.getOutputStream())) {
- Marshaller marsh = new JdkMarshaller();
-
- for (int i = 0; i < CNT; i++) {
- byte[] msg = U.toArray(marsh.marshal(new Tuple(i)));
-
- os.write(msg.length >>> 24);
- os.write(msg.length >>> 16);
- os.write(msg.length >>> 8);
- os.write(msg.length);
-
- os.write(msg);
- }
- }
- catch (IOException | IgniteCheckedException e) {
- throw new IgniteException(e);
- }
- }
- });
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSizeBasedCustomConverter() throws Exception {
- SocketMessageConverter<Tuple> converter = new SocketMessageConverter<Tuple>() {
- @Override public Tuple convert(byte[] msg) {
- int i = (msg[0] & 0xFF) << 24;
- i |= (msg[1] & 0xFF) << 16;
- i |= (msg[2] & 0xFF) << 8;
- i |= msg[3] & 0xFF;
-
- return new Tuple(i);
- }
- };
-
- test(converter, null, new Runnable() {
- @Override public void run() {
- try(Socket sock = new Socket(InetAddress.getLocalHost(), port);
- OutputStream os = new BufferedOutputStream(sock.getOutputStream())) {
-
- for (int i = 0; i < CNT; i++) {
- os.write(0);
- os.write(0);
- os.write(0);
- os.write(4);
-
- os.write(i >>> 24);
- os.write(i >>> 16);
- os.write(i >>> 8);
- os.write(i);
- }
- }
- catch (IOException e) {
- throw new IgniteException(e);
- }
- }
- });
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDelimiterBasedDefaultConverter() throws Exception {
- test(null, DELIM, new Runnable() {
- @Override public void run() {
- try(Socket sock = new Socket(InetAddress.getLocalHost(), port);
- OutputStream os = new BufferedOutputStream(sock.getOutputStream())) {
- Marshaller marsh = new JdkMarshaller();
-
- for (int i = 0; i < CNT; i++) {
- byte[] msg = U.toArray(marsh.marshal(new Tuple(i)));
-
- os.write(msg);
- os.write(DELIM);
- }
- }
- catch (IOException | IgniteCheckedException e) {
- throw new IgniteException(e);
- }
- }
- });
-
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDelimiterBasedCustomConverter() throws Exception {
- SocketMessageConverter<Tuple> converter = new SocketMessageConverter<Tuple>() {
- @Override public Tuple convert(byte[] msg) {
- int i = (msg[0] & 0xFF) << 24;
- i |= (msg[1] & 0xFF) << 16;
- i |= (msg[2] & 0xFF) << 8;
- i |= msg[3] & 0xFF;
-
- return new Tuple(i);
- }
- };
-
- test(converter, DELIM, new Runnable() {
- @Override public void run() {
- try(Socket sock = new Socket(InetAddress.getLocalHost(), port);
- OutputStream os = new BufferedOutputStream(sock.getOutputStream())) {
-
- for (int i = 0; i < CNT; i++) {
- os.write(i >>> 24);
- os.write(i >>> 16);
- os.write(i >>> 8);
- os.write(i);
-
- os.write(DELIM);
- }
- }
- catch (IOException e) {
- throw new IgniteException(e);
- }
- }
- });
- }
-
- /**
- * @param converter Converter.
- * @param r Runnable..
- */
- private void test(@Nullable SocketMessageConverter<Tuple> converter, @Nullable byte[] delim, Runnable r) throws Exception
- {
- SocketStreamer<Tuple, Integer, String> sockStmr = null;
-
- try (IgniteDataStreamer<Integer, String> stmr = ignite.dataStreamer(null)) {
-
- stmr.allowOverwrite(true);
- stmr.autoFlushFrequency(10);
-
- sockStmr = new SocketStreamer<>();
-
- IgniteCache<Integer, String> cache = ignite.cache(null);
-
- sockStmr.setIgnite(ignite);
-
- sockStmr.setStreamer(stmr);
-
- sockStmr.setPort(port);
-
- sockStmr.setDelimiter(delim);
-
- sockStmr.setTupleExtractor(new StreamTupleExtractor<Tuple, Integer, String>() {
- @Override public Map.Entry<Integer, String> extract(Tuple msg) {
- return new IgniteBiTuple<>(msg.key, msg.val);
- }
- });
-
- if (converter != null)
- sockStmr.setConverter(converter);
-
- final CountDownLatch latch = new CountDownLatch(CNT);
-
- IgniteBiPredicate<UUID, CacheEvent> locLsnr = new IgniteBiPredicate<UUID, CacheEvent>() {
- @Override public boolean apply(UUID uuid, CacheEvent evt) {
- latch.countDown();
-
- return true;
- }
- };
-
- ignite.events(ignite.cluster().forCacheNodes(null)).remoteListen(locLsnr, null, EVT_CACHE_OBJECT_PUT);
-
- sockStmr.start();
-
- r.run();
-
- latch.await();
-
- assertEquals(CNT, cache.size(CachePeekMode.PRIMARY));
-
- for (int i = 0; i < CNT; i++)
- assertEquals(Integer.toString(i), cache.get(i));
- }
- finally {
- if (sockStmr != null)
- sockStmr.stop();
- }
-
- }
-
- /**
- * Tuple.
- */
- private static class Tuple implements Serializable {
- /** Serial version uid. */
- private static final long serialVersionUID = 0L;
-
- /** Key. */
- private final int key;
-
- /** Value. */
- private final String val;
-
- /**
- * @param key Key.
- */
- Tuple(int key) {
- this.key = key;
- this.val = Integer.toString(key);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/stream/socket/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/stream/socket/package-info.java b/modules/core/src/test/java/org/apache/ignite/stream/socket/package-info.java
deleted file mode 100644
index 2e28469..0000000
--- a/modules/core/src/test/java/org/apache/ignite/stream/socket/package-info.java
+++ /dev/null
@@ -1,21 +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.
- */
-
-/**
- * Contains tests for socket streamer.
- */
-package org.apache.ignite.stream.socket;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
index dd3ce27..529bd23 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
@@ -54,6 +54,11 @@ public class IgniteCacheFailoverTestSuite extends TestSuite {
suite.addTestSuite(GridCacheAtomicPrimaryWriteOrderFailoverSelfTest.class);
suite.addTestSuite(GridCacheAtomicReplicatedFailoverSelfTest.class);
+ // TODO IGNITE-157.
+ // suite.addTestSuite(GridCachePartitionedFailoverSelfTest.class);
+ // suite.addTestSuite(GridCacheColocatedFailoverSelfTest.class);
+ // suite.addTestSuite(GridCacheReplicatedFailoverSelfTest.class);
+
suite.addTestSuite(IgniteCacheAtomicNodeJoinTest.class);
suite.addTestSuite(IgniteCacheTxNodeJoinTest.class);
suite.addTestSuite(IgniteCacheTxFairAffinityNodeJoinTest.class);
@@ -61,11 +66,6 @@ public class IgniteCacheFailoverTestSuite extends TestSuite {
suite.addTestSuite(IgniteCacheTxNearDisabledPutGetRestartTest.class);
suite.addTestSuite(IgniteCacheTxNearDisabledFairAffinityPutGetRestartTest.class);
- // TODO IGNITE-882.
- //suite.addTestSuite(GridCachePartitionedFailoverSelfTest.class);
- //suite.addTestSuite(GridCacheColocatedFailoverSelfTest.class);
- //suite.addTestSuite(GridCacheReplicatedFailoverSelfTest.class);
-
return suite;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java
index 24945dd..a449cfc 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java
@@ -35,10 +35,10 @@ public class IgniteCacheRestartTestSuite extends TestSuite {
suite.addTestSuite(GridCachePartitionedTxSalvageSelfTest.class);
- // TODO IGNITE-882.
- //suite.addTestSuite(GridCachePartitionedNodeRestartTest.class);
- //suite.addTestSuite(GridCachePartitionedOptimisticTxNodeRestartTest.class);
- //suite.addTestSuite(GridCacheReplicatedNodeRestartSelfTest.class);
+ // TODO: IGNITE-157.
+ // suite.addTestSuite(GridCachePartitionedNodeRestartTest.class);
+ // suite.addTestSuite(GridCachePartitionedOptimisticTxNodeRestartTest.class);
+ // suite.addTestSuite(GridCacheReplicatedNodeRestartSelfTest.class);
suite.addTestSuite(IgniteCacheAtomicNodeRestartTest.class);
// suite.addTestSuite(IgniteCacheAtomicReplicatedNodeRestartSelfTest.class); // TODO IGNITE-747
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
index 5738778..dfd88a8 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
@@ -58,7 +58,6 @@ public class IgniteCacheTestSuite2 extends TestSuite {
suite.addTestSuite(GridCachePartitionedGetSelfTest.class);
suite.addTest(new TestSuite(GridCachePartitionedBasicApiTest.class));
suite.addTest(new TestSuite(GridCacheNearMultiGetSelfTest.class));
- suite.addTest(new TestSuite(NoneRebalanceModeSelfTest.class));
suite.addTest(new TestSuite(GridCacheNearJobExecutionSelfTest.class));
suite.addTest(new TestSuite(GridCacheNearOneNodeSelfTest.class));
suite.addTest(new TestSuite(GridCacheNearMultiNodeSelfTest.class));
@@ -77,7 +76,6 @@ public class IgniteCacheTestSuite2 extends TestSuite {
suite.addTest(new TestSuite(GridCachePartitionedNearDisabledBasicStoreMultiNodeSelfTest.class));
suite.addTest(new TestSuite(GridCachePartitionedEventSelfTest.class));
suite.addTest(new TestSuite(GridCachePartitionedLockSelfTest.class));
- suite.addTest(new TestSuite(GridCachePartitionedNearDisabledLockSelfTest.class));
suite.addTest(new TestSuite(GridCachePartitionedMultiNodeLockSelfTest.class));
suite.addTest(new TestSuite(GridCachePartitionedMultiNodeSelfTest.class));
suite.addTest(new TestSuite(GridCachePartitionedMultiThreadedPutGetSelfTest.class));
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
index c2b56ca..9394693 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
@@ -135,8 +135,6 @@ public class IgniteCacheTestSuite3 extends TestSuite {
// Cache interceptor tests.
suite.addTest(IgniteCacheInterceptorSelfTestSuite.suite());
- suite.addTestSuite(IgniteTxGetAfterStopTest.class);
-
return suite;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index aaf7e5b..f7272d4 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -126,10 +126,6 @@ public class IgniteCacheTestSuite4 extends TestSuite {
suite.addTestSuite(CacheNoValueClassOnServerNodeTest.class);
- suite.addTestSuite(CacheRemoveAllSelfTest.class);
-
- suite.addTestSuite(CacheOffheapMapEntrySelfTest.class);
-
return suite;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStreamTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStreamTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStreamTestSuite.java
deleted file mode 100644
index 61be976..0000000
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStreamTestSuite.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.testsuites;
-
-import org.apache.ignite.stream.socket.*;
-
-import junit.framework.*;
-
-/**
- * Stream test suite.
- */
-public class IgniteStreamTestSuite extends TestSuite {
- /**
- * @return Stream tests suite.
- * @throws Exception If failed.
- */
- public static TestSuite suite() throws Exception {
- TestSuite suite = new TestSuite("Ignite Stream Test Suite");
-
- suite.addTest(new TestSuite(SocketStreamerSelfTest.class));
-
- return suite;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java
index 32cd038..941b06e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java
@@ -67,7 +67,6 @@ public class IgniteUtilSelfTestSuite extends TestSuite {
suite.addTestSuite(GridNioSelfTest.class);
suite.addTestSuite(GridNioFilterChainSelfTest.class);
suite.addTestSuite(GridNioSslSelfTest.class);
- suite.addTestSuite(GridNioDelimitedBufferTest.class);
return suite;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java
deleted file mode 100644
index 4e40040..0000000
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java
+++ /dev/null
@@ -1,111 +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.internal.processors.cache;
-
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.spi.swapspace.file.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.cache.CacheMemoryMode.*;
-import static org.apache.ignite.cache.CacheMode.*;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
-import static org.apache.ignite.configuration.DeploymentMode.*;
-
-/**
- * Tests off heap storage when both offheaped and swapped entries exists.
- */
-public class GridCacheOffheapIndexGetSelfTest extends GridCommonAbstractTest {
- /** */
- private static final long OFFHEAP_MEM = 10L * 1024L;
-
- /** */
- private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
- disco.setIpFinder(ipFinder);
-
- cfg.setDiscoverySpi(disco);
-
- cfg.setNetworkTimeout(2000);
-
- cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
-
- CacheConfiguration cacheCfg = defaultCacheConfiguration();
-
- cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
- cacheCfg.setSwapEnabled(true);
- cacheCfg.setCacheMode(PARTITIONED);
- cacheCfg.setBackups(1);
- cacheCfg.setOffHeapMaxMemory(OFFHEAP_MEM);
- cacheCfg.setEvictSynchronized(true);
- cacheCfg.setEvictSynchronizedKeyBufferSize(1);
- cacheCfg.setAtomicityMode(TRANSACTIONAL);
- cacheCfg.setMemoryMode(OFFHEAP_TIERED);
- cacheCfg.setEvictionPolicy(null);
- cacheCfg.setOffHeapMaxMemory(OFFHEAP_MEM);
- cacheCfg.setIndexedTypes(Long.class, Long.class);
-
- cfg.setCacheConfiguration(cacheCfg);
-
- cfg.setDeploymentMode(SHARED);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- startGrids(2);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- grid(0).cache(null).clear();
- }
-
- /**
- * Tests behavior on offheaped entries.
- *
- * @throws Exception If failed.
- */
- public void testGet() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-873");
-
- IgniteCache<Long, Long> cache = grid(0).cache(null);
-
- for (long i = 0; i < 100; i++)
- cache.put(i, i);
-
- for (long i = 0; i < 100; i++)
- assertEquals((Long)i, cache.get(i));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
index ae45120..a2ccc82 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
@@ -46,8 +46,6 @@ public class IgniteCacheWithIndexingTestSuite extends TestSuite {
suite.addTestSuite(CacheTtlOnheapAtomicLocalSelfTest.class);
suite.addTestSuite(CacheTtlOnheapAtomicPartitionedSelfTest.class);
- suite.addTestSuite(GridCacheOffheapIndexGetSelfTest.class);
-
suite.addTestSuite(CacheConfigurationP2PTest.class);
return suite;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java b/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java
index 9af29d6..56bd676 100644
--- a/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java
+++ b/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java
@@ -85,7 +85,9 @@ public class CacheJtaManager extends CacheJtaManagerAdapter {
tCfg.getDefaultTxIsolation(),
tCfg.getDefaultTxTimeout(),
/*store enabled*/true,
- /*tx size*/0
+ /*tx size*/0,
+ /*group lock keys*/null,
+ /*partition lock*/false
);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarCacheQueriesSpec.scala
----------------------------------------------------------------------
diff --git a/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarCacheQueriesSpec.scala b/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarCacheQueriesSpec.scala
index 2a11e5e..8d91fdc 100644
--- a/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarCacheQueriesSpec.scala
+++ b/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarCacheQueriesSpec.scala
@@ -31,7 +31,7 @@ import scala.collection.JavaConversions._
* Tests for Scalar cache queries API.
*/
@RunWith(classOf[JUnitRunner])
-class ScalarCacheQueriesSpec extends FunSpec with ShouldMatchers with BeforeAndAfterAll {
+class ScalarCacheQueriesSpec extends FlatSpec with ShouldMatchers with BeforeAndAfterAll {
/** Entries count. */
private val ENTRY_CNT = 10
@@ -67,142 +67,142 @@ class ScalarCacheQueriesSpec extends FunSpec with ShouldMatchers with BeforeAndA
stop()
}
- describe("Scalar cache queries API") {
- it("should correctly execute SCAN queries") {
- var res = c.scan(classOf[ObjectValue], (k: Int, v: ObjectValue) => k > 5 && v.intVal < 8).getAll
+ behavior of "Scalar cache queries API"
- assert(res.size == 2)
+ it should "correctly execute SCAN queries" in {
+ var res = c.scan(classOf[ObjectValue], (k: Int, v: ObjectValue) => k > 5 && v.intVal < 8).getAll
- res.foreach(t => assert(t.getKey > 5 && t.getKey < 8 && t.getKey == t.getValue.intVal))
+ assert(res.size == 2)
- res = c.scan((k: Int, v: ObjectValue) => k > 5 && v.intVal < 8).getAll
+ res.foreach(t => assert(t.getKey > 5 && t.getKey < 8 && t.getKey == t.getValue.intVal))
- assert(res.size == 2)
+ res = c.scan((k: Int, v: ObjectValue) => k > 5 && v.intVal < 8).getAll
- res.foreach(t => assert(t.getKey > 5 && t.getKey < 8 && t.getKey == t.getValue.intVal))
+ assert(res.size == 2)
- res = c.scan(classOf[ObjectValue], (k: Int, v: ObjectValue) => k > 5 && v.intVal < 8).getAll
+ res.foreach(t => assert(t.getKey > 5 && t.getKey < 8 && t.getKey == t.getValue.intVal))
- assert(res.size == 2)
+ res = c.scan(classOf[ObjectValue], (k: Int, v: ObjectValue) => k > 5 && v.intVal < 8).getAll
- res.foreach(t => assert(t.getKey > 5 && t.getKey < 8 && t.getKey == t.getValue.intVal))
+ assert(res.size == 2)
- res = c.scan((k: Int, v: ObjectValue) => k > 5 && v.intVal < 8).getAll
+ res.foreach(t => assert(t.getKey > 5 && t.getKey < 8 && t.getKey == t.getValue.intVal))
- assert(res.size == 2)
+ res = c.scan((k: Int, v: ObjectValue) => k > 5 && v.intVal < 8).getAll
- res.foreach(t => assert(t.getKey > 5 && t.getKey < 8 && t.getKey == t.getValue.intVal))
- }
+ assert(res.size == 2)
- it("should correctly execute SQL queries") {
- var res = c.sql(classOf[ObjectValue], "intVal > 5").getAll
+ res.foreach(t => assert(t.getKey > 5 && t.getKey < 8 && t.getKey == t.getValue.intVal))
+ }
- assert(res.size == ENTRY_CNT - 5)
+ it should "correctly execute SQL queries" in {
+ var res = c.sql(classOf[ObjectValue], "intVal > 5").getAll
- res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
+ assert(res.size == ENTRY_CNT - 5)
- res = c.sql(classOf[ObjectValue], "intVal > ?", 5).getAll
+ res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
- assert(res.size == ENTRY_CNT - 5)
+ res = c.sql(classOf[ObjectValue], "intVal > ?", 5).getAll
- res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
+ assert(res.size == ENTRY_CNT - 5)
- res = c.sql("intVal > 5").getAll
+ res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
- assert(res.size == ENTRY_CNT - 5)
+ res = c.sql("intVal > 5").getAll
- res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
+ assert(res.size == ENTRY_CNT - 5)
- res = c.sql("intVal > ?", 5).getAll
+ res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
- assert(res.size == ENTRY_CNT - 5)
+ res = c.sql("intVal > ?", 5).getAll
- res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
+ assert(res.size == ENTRY_CNT - 5)
- res = c.sql(classOf[ObjectValue], "intVal > 5").getAll
+ res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
- assert(res.size == ENTRY_CNT - 5)
+ res = c.sql(classOf[ObjectValue], "intVal > 5").getAll
- res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
+ assert(res.size == ENTRY_CNT - 5)
- res = c.sql(classOf[ObjectValue], "intVal > ?", 5).getAll
+ res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
- assert(res.size == ENTRY_CNT - 5)
+ res = c.sql(classOf[ObjectValue], "intVal > ?", 5).getAll
- res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
+ assert(res.size == ENTRY_CNT - 5)
- res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
+ res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
- res = c.sql("intVal > 5").getAll
+ res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
- assert(res.size == ENTRY_CNT - 5)
+ res = c.sql("intVal > 5").getAll
- res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
+ assert(res.size == ENTRY_CNT - 5)
- res = c.sql("intVal > ?", 5).getAll
+ res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
- assert(res.size == ENTRY_CNT - 5)
+ res = c.sql("intVal > ?", 5).getAll
- res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
- }
+ assert(res.size == ENTRY_CNT - 5)
- it("should correctly execute TEXT queries") {
- var res = c.text(classOf[ObjectValue], "str").getAll
+ res.foreach(t => assert(t.getKey > 5 && t.getKey == t.getValue.intVal))
+ }
- assert(res.size == ENTRY_CNT)
+ it should "correctly execute TEXT queries" in {
+ var res = c.text(classOf[ObjectValue], "str").getAll
- res = c.text(classOf[ObjectValue], "five").getAll
+ assert(res.size == ENTRY_CNT)
- assert(res.size == 1)
- assert(res.head.getKey == 5)
+ res = c.text(classOf[ObjectValue], "five").getAll
- res = c.text("str").getAll
+ assert(res.size == 1)
+ assert(res.head.getKey == 5)
- assert(res.size == ENTRY_CNT)
+ res = c.text("str").getAll
- res = c.text("five").getAll
+ assert(res.size == ENTRY_CNT)
- assert(res.size == 1)
- assert(res.head.getKey == 5)
+ res = c.text("five").getAll
- res = c.text(classOf[ObjectValue], "str").getAll
+ assert(res.size == 1)
+ assert(res.head.getKey == 5)
- assert(res.size == ENTRY_CNT)
+ res = c.text(classOf[ObjectValue], "str").getAll
- res = c.text(classOf[ObjectValue], "five").getAll
+ assert(res.size == ENTRY_CNT)
- assert(res.size == 1)
- assert(res.head.getKey == 5)
+ res = c.text(classOf[ObjectValue], "five").getAll
- res = c.text("str").getAll
+ assert(res.size == 1)
+ assert(res.head.getKey == 5)
- assert(res.size == ENTRY_CNT)
+ res = c.text("str").getAll
- res = c.text("five").getAll
+ assert(res.size == ENTRY_CNT)
- assert(res.size == 1)
- assert(res.head.getKey == 5)
- }
+ res = c.text("five").getAll
- it("should correctly execute fields queries") {
- var res = c.sqlFields("select intVal from ObjectValue where intVal > 5").getAll
+ assert(res.size == 1)
+ assert(res.head.getKey == 5)
+ }
- assert(res.size == ENTRY_CNT - 5)
+ it should "correctly execute fields queries" in {
+ var res = c.sqlFields("select intVal from ObjectValue where intVal > 5").getAll
- res.foreach(t => assert(t.size == 1 && t.head.asInstanceOf[Int] > 5))
+ assert(res.size == ENTRY_CNT - 5)
- res = c.sqlFields("select intVal from ObjectValue where intVal > ?", 5).getAll
+ res.foreach(t => assert(t.size == 1 && t.head.asInstanceOf[Int] > 5))
- assert(res.size == ENTRY_CNT - 5)
+ res = c.sqlFields("select intVal from ObjectValue where intVal > ?", 5).getAll
- res.foreach(t => assert(t.size == 1 && t.head.asInstanceOf[Int] > 5))
- }
+ assert(res.size == ENTRY_CNT - 5)
+
+ res.foreach(t => assert(t.size == 1 && t.head.asInstanceOf[Int] > 5))
+ }
- it("should correctly execute queries with multiple arguments") {
- val res = c.sql("from ObjectValue where intVal in (?, ?, ?)", 1, 2, 3).getAll
+ it should "correctly execute queries with multiple arguments" in {
+ val res = c.sql("from ObjectValue where intVal in (?, ?, ?)", 1, 2, 3).getAll
- assert(res.size == 3)
- }
+ assert(res.size == 3)
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarCacheSpec.scala
----------------------------------------------------------------------
diff --git a/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarCacheSpec.scala b/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarCacheSpec.scala
index 853cc16..0fde48f 100644
--- a/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarCacheSpec.scala
+++ b/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarCacheSpec.scala
@@ -22,35 +22,32 @@ import org.apache.ignite.events.EventType._
import org.apache.ignite.lang.IgnitePredicate
import org.apache.ignite.scalar.scalar
import org.apache.ignite.scalar.scalar._
-
import org.junit.runner.RunWith
import org.scalatest._
import org.scalatest.junit.JUnitRunner
-
import scala.collection.JavaConversions._
/**
* Scalar cache test.
*/
@RunWith(classOf[JUnitRunner])
-class ScalarCacheSpec extends FunSpec with ShouldMatchers {
+class ScalarCacheSpec extends FlatSpec with ShouldMatchers {
private val CFG = "modules/scalar/src/test/resources/spring-cache.xml"
- describe("Scalar cache") {
+ behavior of "Scalar cache"
- it("should work properly via Java APIs") {
- scalar(CFG) {
- registerListener()
+ it should "work properly via Java APIs" in {
+ scalar(CFG) {
+ registerListener()
- val c = cache$[Int, Int]("partitioned").get
+ val c = cache$[Int, Int]("partitioned").get
- c.put(1, 1)
- c.put(2, 2)
+ c.put(1, 1)
+ c.put(2, 2)
- c.iterator() foreach println
+ c.iterator() foreach println
- println("Size is: " + c.size())
- }
+ println("Size is: " + c.size())
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarConversionsSpec.scala
----------------------------------------------------------------------
diff --git a/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarConversionsSpec.scala b/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarConversionsSpec.scala
index c766422..b20c755 100644
--- a/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarConversionsSpec.scala
+++ b/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarConversionsSpec.scala
@@ -21,7 +21,7 @@ import org.apache.ignite.internal.util.lang._
import org.apache.ignite.lang._
import org.apache.ignite.scalar.scalar._
import org.junit.runner.RunWith
-import org.scalatest._
+import org.scalatest.FlatSpec
import org.scalatest.junit.JUnitRunner
import org.scalatest.matchers.ShouldMatchers
@@ -31,10 +31,10 @@ import java.util.concurrent.atomic._
*
*/
@RunWith(classOf[JUnitRunner])
-class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
- describe("Scalar mixin") {
+class ScalarConversionsSpec extends FlatSpec with ShouldMatchers {
+ behavior of "Scalar mixin"
- it("should convert reducer") {
+ it should "convert reducer" in {
val r = new IgniteReducer[Int, Int] {
var sum = 0
@@ -52,7 +52,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(r.scala.apply(Seq(1, 2, 3)) == 6)
}
- it("should convert reducer 2") {
+ it should "convert reducer 2" in {
val r = new IgniteReducer2[Int, Int, Int] {
var sum = 0
@@ -70,7 +70,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(r.scala.apply(Seq(1, 2), Seq(3, 4)) == 21)
}
- it("should convert reducer 3") {
+ it should "convert reducer 3" in {
val r = new IgniteReducer3[Int, Int, Int, Int] {
var sum = 0
@@ -88,14 +88,14 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(r.scala.apply(Seq(1, 2), Seq(1, 2), Seq(1, 2)) == 27)
}
- it("should convert tuple 2") {
+ it should "convert tuple 2" in {
val t = new IgniteBiTuple[Int, Int](1, 2)
assert(t.scala._1 == 1)
assert(t.scala._2 == 2)
}
- it("should convert tuple 3") {
+ it should "convert tuple 3" in {
val t = new GridTuple3[Int, Int, Int](1, 2, 3)
assert(t.scala._1 == 1)
@@ -103,7 +103,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(t.scala._3 == 3)
}
- it("should convert tuple 4") {
+ it should "convert tuple 4" in {
val t = new GridTuple4[Int, Int, Int, Int](1, 2, 3, 4)
assert(t.scala._1 == 1)
@@ -112,7 +112,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(t.scala._4 == 4)
}
- it("should convert tuple 5") {
+ it should "convert tuple 5" in {
val t = new GridTuple5[Int, Int, Int, Int, Int](1, 2, 3, 4, 5)
assert(t.scala._1 == 1)
@@ -122,7 +122,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(t.scala._5 == 5)
}
- it("should convert in closure") {
+ it should "convert in closure" in {
val i = new AtomicInteger()
val f = new IgniteInClosure[Int] {
@@ -136,7 +136,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(i.get == 9)
}
- it("should convert in closure 2") {
+ it should "convert in closure 2" in {
val i = new AtomicInteger()
val f = new IgniteBiInClosure[Int, Int] {
@@ -150,7 +150,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(i.get == 6)
}
- it("should convert in closure 3") {
+ it should "convert in closure 3" in {
val i = new AtomicInteger()
val f = new GridInClosure3[Int, Int, Int] {
@@ -164,7 +164,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(i.get == 9)
}
- it("should convert absolute closure") {
+ it should "convert absolute closure" in {
val i = new AtomicInteger()
val f = new GridAbsClosure {
@@ -178,7 +178,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(i.get == 3)
}
- it("should convert absolute predicate") {
+ it should "convert absolute predicate" in {
val i = new AtomicInteger()
val p = new GridAbsPredicate {
@@ -195,7 +195,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(p.scala.apply())
}
- it("should convert predicate") {
+ it should "convert predicate" in {
val p = new IgnitePredicate[Int] {
override def apply(e: Int): Boolean =
e > 5
@@ -205,7 +205,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(p.scala.apply(6))
}
- it("should convert predicate 2") {
+ it should "convert predicate 2" in {
val p = new IgniteBiPredicate[Int, Int] {
override def apply(e1: Int, e2: Int): Boolean =
e1 + e2 > 5
@@ -215,7 +215,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(p.scala.apply(3, 3))
}
- it("should convert predicate 3") {
+ it should "convert predicate 3" in {
val p = new GridPredicate3[Int, Int, Int] {
override def apply(e1: Int, e2: Int, e3: Int): Boolean =
e1 + e2 + e3 > 5
@@ -225,7 +225,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(p.scala.apply(2, 2, 2))
}
- it("should convert closure") {
+ it should "convert closure" in {
val f = new IgniteClosure[Int, Int] {
override def apply(e: Int): Int =
e * 3
@@ -234,7 +234,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(f.scala.apply(3) == 9)
}
- it("should convert closure 2") {
+ it should "convert closure 2" in {
val f = new IgniteBiClosure[Int, Int, Int] {
override def apply(e1: Int, e2: Int): Int =
e1 + e2
@@ -243,7 +243,7 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(f.scala.apply(3, 3) == 6)
}
- it("should convert closure 3") {
+ it should "convert closure 3" in {
val f = new GridClosure3[Int, Int, Int, Int] {
override def apply(e1: Int, e2: Int, e3: Int): Int =
e1 + e2 + e3
@@ -251,5 +251,4 @@ class ScalarConversionsSpec extends FunSpec with ShouldMatchers {
assert(f.scala.apply(3, 3, 3) == 9)
}
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarProjectionSpec.scala
----------------------------------------------------------------------
diff --git a/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarProjectionSpec.scala b/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarProjectionSpec.scala
index ecb1e5a..a035550 100644
--- a/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarProjectionSpec.scala
+++ b/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarProjectionSpec.scala
@@ -23,7 +23,6 @@ import org.apache.ignite.configuration.IgniteConfiguration
import org.apache.ignite.messaging.MessagingListenActor
import org.apache.ignite.scalar.scalar
import org.apache.ignite.scalar.scalar._
-
import org.junit.runner.RunWith
import org.scalatest._
import org.scalatest.junit.JUnitRunner
@@ -36,7 +35,7 @@ import scala.collection.JavaConversions._
* Scalar cache test.
*/
@RunWith(classOf[JUnitRunner])
-class ScalarProjectionSpec extends FunSpec with ShouldMatchers with BeforeAndAfterAll {
+class ScalarProjectionSpec extends FlatSpec with ShouldMatchers with BeforeAndAfterAll {
/**
*
*/
@@ -69,95 +68,82 @@ class ScalarProjectionSpec extends FunSpec with ShouldMatchers with BeforeAndAft
cfg
}
- describe("ScalarProjectionPimp class") {
- it("should return all nodes") {
- scalar(gridConfig("node-scalar", true)) {
- assertResult(3)(ignite$("node-scalar").get.cluster().nodes().size)
- }
- }
+ behavior of "ScalarProjectionPimp class"
- it("should return shown nodes") {
- scalar(gridConfig("node-scalar", true)) {
- assert(ignite$("node-scalar").get.nodes$(
- (node: ClusterNode) => node.attribute[Boolean]("shown")).size == 2)
- }
+ it should "return all nodes" in scalar(gridConfig("node-scalar", true)) {
+ assertResult(3) {
+ ignite$("node-scalar").get.cluster().nodes().size
}
+ }
- it("should return all remote nodes") {
- scalar(gridConfig("node-scalar", true)) {
- assertResult(2)(ignite$("node-scalar").get.remoteNodes$().size)
- }
+ it should "return shown nodes" in scalar(gridConfig("node-scalar", true)) {
+ assert(ignite$("node-scalar").get.nodes$((node: ClusterNode) => node.attribute[Boolean]("shown")).size == 2)
+ }
+
+ it should "return all remote nodes" in scalar(gridConfig("node-scalar", true)) {
+ assertResult(2) {
+ ignite$("node-scalar").get.remoteNodes$().size
}
+ }
+
+ it should "return shown remote nodes" in scalar(gridConfig("node-scalar", true)) {
+ assert(ignite$("node-scalar").get.remoteNodes$((node: ClusterNode) =>
+ node.attribute[Boolean]("shown")).size == 1)
+ }
+
+ it should "correctly send messages" in scalar(gridConfig("node-scalar", true)) {
- it("should return shown remote nodes") {
- scalar(gridConfig("node-scalar", true)) {
- assert(ignite$("node-scalar").get.remoteNodes$((node: ClusterNode) =>
- node.attribute[Boolean]("shown")).size == 1)
+ ignite$("node-1").get.message().remoteListen(null, new MessagingListenActor[Any]() {
+ def receive(nodeId: UUID, msg: Any) {
+ println("node-1 received " + msg)
}
- }
+ })
- it("should correctly send messages") {
- scalar(gridConfig("node-scalar", true)) {
- ignite$("node-1").get.message().remoteListen(null, new MessagingListenActor[Any]() {
- def receive(nodeId: UUID, msg: Any) {
- println("node-1 received " + msg)
- }
- })
-
- ignite$("node-2").get.message().remoteListen(null, new MessagingListenActor[Any]() {
- def receive(nodeId: UUID, msg: Any) {
- println("node-2 received " + msg)
- }
- })
-
- ignite$("node-scalar").get !<("Message", null)
- ignite$("node-scalar").get !<(Seq("Message1", "Message2"), null)
+ ignite$("node-2").get.message().remoteListen(null, new MessagingListenActor[Any]() {
+ def receive(nodeId: UUID, msg: Any) {
+ println("node-2 received " + msg)
}
- }
+ })
+
+ ignite$("node-scalar").get !< ("Message", null)
+ ignite$("node-scalar").get !< (Seq("Message1", "Message2"), null)
+ }
- it("should correctly make calls") {
- scalar(gridConfig("node-scalar", true)) {
- println("CALL RESULT: " + ignite$("node-scalar").get #<(() => "Message", null))
+ it should "correctly make calls" in scalar(gridConfig("node-scalar", true)) {
+ println("CALL RESULT: " + ignite$("node-scalar").get #< (() => "Message", null))
- println("ASYNC CALL RESULT: " + ignite$("node-scalar").get.callAsync$[String](() => "Message", null).get)
+ println("ASYNC CALL RESULT: " + ignite$("node-scalar").get.callAsync$[String](() => "Message", null).get)
- val call1: () => String = () => "Message1"
- val call2: () => String = () => "Message2"
+ val call1: () => String = () => "Message1"
+ val call2: () => String = () => "Message2"
- println("MULTIPLE CALL RESULT: " + ignite$("node-scalar").get #<(Seq(call1, call2), null))
+ println("MULTIPLE CALL RESULT: " + ignite$("node-scalar").get #< (Seq(call1, call2), null))
- println("MULTIPLE ASYNC CALL RESULT: " +
- (ignite$("node-scalar").get #?(Seq(call1, call2), null)).get)
- }
- }
+ println("MULTIPLE ASYNC CALL RESULT: " +
+ (ignite$("node-scalar").get #? (Seq(call1, call2), null)).get)
+ }
- it("should correctly make runs") {
- scalar(gridConfig("node-scalar", true)) {
- ignite$("node-scalar").get *<(() => println("RUN RESULT: Message"), null)
+ it should "correctly make runs" in scalar(gridConfig("node-scalar", true)) {
+ ignite$("node-scalar").get *< (() => println("RUN RESULT: Message"), null)
- (ignite$("node-scalar").get *?(() => println("ASYNC RUN RESULT: Message"), null)).get
+ (ignite$("node-scalar").get *? (() => println("ASYNC RUN RESULT: Message"), null)).get
- val run1: () => Unit = () => println("RUN 1 RESULT: Message1")
- val run2: () => Unit = () => println("RUN 2 RESULT: Message2")
+ val run1: () => Unit = () => println("RUN 1 RESULT: Message1")
+ val run2: () => Unit = () => println("RUN 2 RESULT: Message2")
- ignite$("node-scalar").get *<(Seq(run1, run2), null)
+ ignite$("node-scalar").get *< (Seq(run1, run2), null)
- val runAsync1: () => Unit = () => println("ASYNC RUN 1 RESULT: Message1")
- val runAsync2: () => Unit = () => println("ASYNC RUN 2 RESULT: Message2")
+ val runAsync1: () => Unit = () => println("ASYNC RUN 1 RESULT: Message1")
+ val runAsync2: () => Unit = () => println("ASYNC RUN 2 RESULT: Message2")
- (ignite$("node-scalar").get *?(Seq(runAsync1, runAsync2), null)).get
- }
- }
+ (ignite$("node-scalar").get *? (Seq(runAsync1, runAsync2), null)).get
+ }
- it("should correctly reduce") {
- scalar(gridConfig("node-scalar", true)) {
- val call1: () => Int = () => 15
- val call2: () => Int = () => 82
+ it should "correctly reduce" in scalar(gridConfig("node-scalar", true)) {
+ val call1: () => Int = () => 15
+ val call2: () => Int = () => 82
- assert(ignite$("node-scalar").get @<(Seq(call1, call2), (n: Seq[Int]) => n.sum, null) == 97)
- assert(ignite$("node-scalar").get.reduceAsync$(Seq(call1, call2), (
- n: Seq[Int]) => n.sum, null).get == 97)
- }
- }
+ assert(ignite$("node-scalar").get @< (Seq(call1, call2), (n: Seq[Int]) => n.sum, null) == 97)
+ assert(ignite$("node-scalar").get.reduceAsync$(Seq(call1, call2), (n: Seq[Int]) => n.sum, null).get == 97)
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarReturnableSpec.scala
----------------------------------------------------------------------
diff --git a/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarReturnableSpec.scala b/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarReturnableSpec.scala
index 2927dd7..21e8cef 100644
--- a/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarReturnableSpec.scala
+++ b/modules/scalar/src/test/scala/org/apache/ignite/scalar/tests/ScalarReturnableSpec.scala
@@ -18,7 +18,6 @@
package org.apache.ignite.scalar.tests
import org.apache.ignite.scalar.scalar._
-
import org.junit.runner.RunWith
import org.scalatest._
import org.scalatest.junit.JUnitRunner
@@ -29,32 +28,30 @@ import scala.util.control.Breaks._
*
*/
@RunWith(classOf[JUnitRunner])
-class ScalarReturnableSpec extends FunSpec with ShouldMatchers {
- describe("Scalar '^^'") {
- it("should work") {
- var i = 0
-
- breakable {
- while (true) {
- if (i == 0)
- println("Only once!") ^^
-
- i += 1
- }
- }
+class ScalarReturnableSpec extends FlatSpec with ShouldMatchers {
+ "Scalar '^^'" should "work" in {
+ var i = 0
- assert(i == 0)
- }
-
- // Ignore exception below.
- def test() = breakable {
+ breakable {
while (true) {
- println("Only once!") ^^
+ if (i == 0)
+ println("Only once!") ^^
+
+ i += 1
}
}
- it("should also work") {
- test()
+ assert(i == 0)
+ }
+
+ "Scalar '^^'" should "also work" in {
+ test()
+ }
+
+ // Ignore exception below.
+ def test() = breakable {
+ while (true) {
+ println("Only once!") ^^
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-console/pom.xml b/modules/visor-console/pom.xml
index 95eb6cf..45e0f30 100644
--- a/modules/visor-console/pom.xml
+++ b/modules/visor-console/pom.xml
@@ -100,7 +100,7 @@
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
- <version>2.2.4</version>
+ <version>2.2.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/visor-console/src/test/scala/org/apache/ignite/visor/VisorRuntimeBaseSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/VisorRuntimeBaseSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/VisorRuntimeBaseSpec.scala
index f27bae3..aa6ab84 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/VisorRuntimeBaseSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/VisorRuntimeBaseSpec.scala
@@ -24,7 +24,7 @@ import org.scalatest._
/**
* Base abstract class for unit tests requiring Visor runtime.
*/
-abstract class VisorRuntimeBaseSpec(private[this] val num: Int) extends FunSpec with Matchers
+abstract class VisorRuntimeBaseSpec(private[this] val num: Int) extends FlatSpec with Matchers
with BeforeAndAfterAll with BeforeAndAfterEach {
assert(num >= 1)
[5/8] incubator-ignite git commit: Revert "ignite-471: fixed NPE in
PortableMarshaller"
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
deleted file mode 100644
index 4f74303..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
+++ /dev/null
@@ -1,768 +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.internal.processors.cache.distributed.near;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.cluster.*;
-import org.apache.ignite.internal.processors.affinity.*;
-import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.processors.cache.distributed.*;
-import org.apache.ignite.internal.processors.cache.distributed.dht.*;
-import org.apache.ignite.internal.processors.cache.transactions.*;
-import org.apache.ignite.internal.transactions.*;
-import org.apache.ignite.internal.util.*;
-import org.apache.ignite.internal.util.future.*;
-import org.apache.ignite.internal.util.lang.*;
-import org.apache.ignite.internal.util.tostring.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.transactions.*;
-import org.jetbrains.annotations.*;
-import org.jsr166.*;
-
-import java.util.*;
-import java.util.concurrent.atomic.*;
-
-import static org.apache.ignite.internal.processors.cache.GridCacheOperation.*;
-import static org.apache.ignite.transactions.TransactionState.*;
-
-/**
- *
- */
-public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAdapter
- implements GridCacheMvccFuture<IgniteInternalTx> {
- /** */
- private Collection<IgniteTxKey> lockKeys = new GridConcurrentHashSet<>();
-
- /**
- * @param cctx Context.
- * @param tx Transaction.
- */
- public GridNearOptimisticTxPrepareFuture(GridCacheSharedContext cctx, GridNearTxLocal tx) {
- super(cctx, tx);
-
- assert tx.optimistic() : tx;
- }
-
- /** {@inheritDoc} */
- @Override public boolean onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner) {
- if (log.isDebugEnabled())
- log.debug("Transaction future received owner changed callback: " + entry);
-
- if ((entry.context().isNear() || entry.context().isLocal()) && owner != null && tx.hasWriteKey(entry.txKey())) {
- lockKeys.remove(entry.txKey());
-
- // This will check for locks.
- onDone();
-
- return true;
- }
-
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public Collection<? extends ClusterNode> nodes() {
- return F.viewReadOnly(futures(), new IgniteClosure<IgniteInternalFuture<?>, ClusterNode>() {
- @Nullable @Override public ClusterNode apply(IgniteInternalFuture<?> f) {
- if (isMini(f))
- return ((MiniFuture)f).node();
-
- return cctx.discovery().localNode();
- }
- });
- }
-
- /** {@inheritDoc} */
- @Override public boolean onNodeLeft(UUID nodeId) {
- boolean found = false;
-
- for (IgniteInternalFuture<?> fut : futures()) {
- if (isMini(fut)) {
- MiniFuture f = (MiniFuture) fut;
-
- if (f.node().id().equals(nodeId)) {
- f.onResult(new ClusterTopologyCheckedException("Remote node left grid: " + nodeId));
-
- found = true;
- }
- }
- }
-
- return found;
- }
-
- /**
- * @param nodeId Failed node ID.
- * @param mappings Remaining mappings.
- * @param e Error.
- */
- void onError(@Nullable UUID nodeId, @Nullable Iterable<GridDistributedTxMapping> mappings, Throwable e) {
- if (err.compareAndSet(null, e)) {
- boolean marked = tx.setRollbackOnly();
-
- if (e instanceof IgniteTxOptimisticCheckedException) {
- assert nodeId != null : "Missing node ID for optimistic failure exception: " + e;
-
- tx.removeKeysMapping(nodeId, mappings);
- }
-
- if (e instanceof IgniteTxRollbackCheckedException) {
- if (marked) {
- try {
- tx.rollback();
- }
- catch (IgniteCheckedException ex) {
- U.error(log, "Failed to automatically rollback transaction: " + tx, ex);
- }
- }
- }
-
- onComplete();
- }
- }
-
- /**
- * @return {@code True} if all locks are owned.
- */
- private boolean checkLocks() {
- boolean locked = lockKeys.isEmpty();
-
- if (locked) {
- if (log.isDebugEnabled())
- log.debug("All locks are acquired for near prepare future: " + this);
- }
- else {
- if (log.isDebugEnabled())
- log.debug("Still waiting for locks [fut=" + this + ", keys=" + lockKeys + ']');
- }
-
- return locked;
- }
-
- /** {@inheritDoc} */
- @Override public void onResult(UUID nodeId, GridNearTxPrepareResponse res) {
- if (!isDone()) {
- for (IgniteInternalFuture<IgniteInternalTx> fut : pending()) {
- if (isMini(fut)) {
- MiniFuture f = (MiniFuture)fut;
-
- if (f.futureId().equals(res.miniId())) {
- assert f.node().id().equals(nodeId);
-
- f.onResult(nodeId, res);
- }
- }
- }
- }
- }
-
- /** {@inheritDoc} */
- @Override public boolean onDone(IgniteInternalTx t, Throwable err) {
- // If locks were not acquired yet, delay completion.
- if (isDone() || (err == null && !checkLocks()))
- return false;
-
- this.err.compareAndSet(null, err);
-
- if (err == null)
- tx.state(PREPARED);
-
- if (super.onDone(tx, err)) {
- // Don't forget to clean up.
- cctx.mvcc().removeFuture(this);
-
- return true;
- }
-
- return false;
- }
-
- /**
- * @param f Future.
- * @return {@code True} if mini-future.
- */
- private boolean isMini(IgniteInternalFuture<?> f) {
- return f.getClass().equals(MiniFuture.class);
- }
-
- /**
- * Completeness callback.
- */
- private void onComplete() {
- if (super.onDone(tx, err.get()))
- // Don't forget to clean up.
- cctx.mvcc().removeFuture(this);
- }
-
- /** {@inheritDoc} */
- @Override public void prepare() {
- // Obtain the topology version to use.
- AffinityTopologyVersion topVer = cctx.mvcc().lastExplicitLockTopologyVersion(Thread.currentThread().getId());
-
- if (topVer != null) {
- tx.topologyVersion(topVer);
-
- prepare0();
-
- return;
- }
-
- prepareOnTopology();
- }
-
- /**
- *
- */
- private void prepareOnTopology() {
- GridDhtTopologyFuture topFut = topologyReadLock();
-
- try {
- if (topFut == null) {
- assert isDone();
-
- return;
- }
-
- if (topFut.isDone()) {
- StringBuilder invalidCaches = new StringBuilder();
-
- boolean cacheInvalid = false;
-
- for (GridCacheContext ctx : cctx.cacheContexts()) {
- if (tx.activeCacheIds().contains(ctx.cacheId()) && !topFut.isCacheTopologyValid(ctx)) {
- if (cacheInvalid)
- invalidCaches.append(", ");
-
- invalidCaches.append(U.maskName(ctx.name()));
-
- cacheInvalid = true;
- }
- }
-
- if (cacheInvalid) {
- onDone(new IgniteCheckedException("Failed to perform cache operation (cache topology is not valid): " +
- invalidCaches.toString()));
-
- return;
- }
-
- tx.topologyVersion(topFut.topologyVersion());
-
- prepare0();
- }
- else {
- topFut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
- @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> t) {
- cctx.kernalContext().closure().runLocalSafe(new GridPlainRunnable() {
- @Override public void run() {
- prepareOnTopology();
- }
- });
- }
- });
- }
- }
- finally {
- topologyReadUnlock();
- }
- }
-
- /**
- * Acquires topology read lock.
- *
- * @return Topology ready future.
- */
- private GridDhtTopologyFuture topologyReadLock() {
- if (tx.activeCacheIds().isEmpty())
- return cctx.exchange().lastTopologyFuture();
-
- GridCacheContext<?, ?> nonLocCtx = null;
-
- for (int cacheId : tx.activeCacheIds()) {
- GridCacheContext<?, ?> cacheCtx = cctx.cacheContext(cacheId);
-
- if (!cacheCtx.isLocal()) {
- nonLocCtx = cacheCtx;
-
- break;
- }
- }
-
- if (nonLocCtx == null)
- return cctx.exchange().lastTopologyFuture();
-
- nonLocCtx.topology().readLock();
-
- if (nonLocCtx.topology().stopping()) {
- onDone(new IgniteCheckedException("Failed to perform cache operation (cache is stopped): " +
- nonLocCtx.name()));
-
- return null;
- }
-
- return nonLocCtx.topology().topologyVersionFuture();
- }
-
- /**
- * Releases topology read lock.
- */
- private void topologyReadUnlock() {
- if (!tx.activeCacheIds().isEmpty()) {
- GridCacheContext<?, ?> nonLocCtx = null;
-
- for (int cacheId : tx.activeCacheIds()) {
- GridCacheContext<?, ?> cacheCtx = cctx.cacheContext(cacheId);
-
- if (!cacheCtx.isLocal()) {
- nonLocCtx = cacheCtx;
-
- break;
- }
- }
-
- if (nonLocCtx != null)
- nonLocCtx.topology().readUnlock();
- }
- }
-
- /**
- * Initializes future.
- */
- private void prepare0() {
- try {
- if (!tx.state(PREPARING)) {
- if (tx.setRollbackOnly()) {
- if (tx.timedOut())
- onError(null, null, new IgniteTxTimeoutCheckedException("Transaction timed out and " +
- "was rolled back: " + this));
- else
- onError(null, null, new IgniteCheckedException("Invalid transaction state for prepare " +
- "[state=" + tx.state() + ", tx=" + this + ']'));
- }
- else
- onError(null, null, new IgniteTxRollbackCheckedException("Invalid transaction state for " +
- "prepare [state=" + tx.state() + ", tx=" + this + ']'));
-
- return;
- }
-
- // Make sure to add future before calling prepare.
- cctx.mvcc().addFuture(this);
-
- prepare(
- tx.optimistic() && tx.serializable() ? tx.readEntries() : Collections.<IgniteTxEntry>emptyList(),
- tx.writeEntries());
-
- markInitialized();
- }
- catch (TransactionTimeoutException | TransactionOptimisticException e) {
- onError(cctx.localNodeId(), null, e);
- }
- catch (IgniteCheckedException e) {
- onDone(e);
- }
- }
-
- /**
- * @param reads Read entries.
- * @param writes Write entries.
- * @throws IgniteCheckedException If transaction is group-lock and some key was mapped to to the local node.
- */
- private void prepare(
- Iterable<IgniteTxEntry> reads,
- Iterable<IgniteTxEntry> writes
- ) throws IgniteCheckedException {
- AffinityTopologyVersion topVer = tx.topologyVersion();
-
- assert topVer.topologyVersion() > 0;
-
- txMapping = new GridDhtTxMapping();
-
- ConcurrentLinkedDeque8<GridDistributedTxMapping> mappings = new ConcurrentLinkedDeque8<>();
-
- if (!F.isEmpty(reads) || !F.isEmpty(writes)) {
- for (int cacheId : tx.activeCacheIds()) {
- GridCacheContext<?, ?> cacheCtx = cctx.cacheContext(cacheId);
-
- if (CU.affinityNodes(cacheCtx, topVer).isEmpty()) {
- onDone(new ClusterTopologyCheckedException("Failed to map keys for cache (all " +
- "partition nodes left the grid): " + cacheCtx.name()));
-
- return;
- }
- }
- }
-
- // Assign keys to primary nodes.
- GridDistributedTxMapping cur = null;
-
- for (IgniteTxEntry read : reads) {
- GridDistributedTxMapping updated = map(read, topVer, cur, false);
-
- if (cur != updated) {
- mappings.offer(updated);
-
- if (updated.node().isLocal()) {
- if (read.context().isNear())
- tx.nearLocallyMapped(true);
- else if (read.context().isColocated())
- tx.colocatedLocallyMapped(true);
- }
-
- cur = updated;
- }
- }
-
- for (IgniteTxEntry write : writes) {
- GridDistributedTxMapping updated = map(write, topVer, cur, true);
-
- if (cur != updated) {
- mappings.offer(updated);
-
- if (updated.node().isLocal()) {
- if (write.context().isNear())
- tx.nearLocallyMapped(true);
- else if (write.context().isColocated())
- tx.colocatedLocallyMapped(true);
- }
-
- cur = updated;
- }
- }
-
- if (isDone()) {
- if (log.isDebugEnabled())
- log.debug("Abandoning (re)map because future is done: " + this);
-
- return;
- }
-
- tx.addEntryMapping(mappings);
-
- cctx.mvcc().recheckPendingLocks();
-
- txMapping.initLast(mappings);
-
- tx.transactionNodes(txMapping.transactionNodes());
-
- checkOnePhase();
-
- proceedPrepare(mappings);
- }
-
- /**
- * Continues prepare after previous mapping successfully finished.
- *
- * @param mappings Queue of mappings.
- */
- private void proceedPrepare(final ConcurrentLinkedDeque8<GridDistributedTxMapping> mappings) {
- if (isDone())
- return;
-
- final GridDistributedTxMapping m = mappings.poll();
-
- if (m == null)
- return;
-
- assert !m.empty();
-
- final ClusterNode n = m.node();
-
- GridNearTxPrepareRequest req = new GridNearTxPrepareRequest(
- futId,
- tx.topologyVersion(),
- tx,
- tx.optimistic() && tx.serializable() ? m.reads() : null,
- m.writes(),
- m.near(),
- txMapping.transactionNodes(),
- m.last(),
- m.lastBackups(),
- tx.onePhaseCommit(),
- tx.needReturnValue() && tx.implicit(),
- tx.implicitSingle(),
- m.explicitLock(),
- tx.subjectId(),
- tx.taskNameHash());
-
- for (IgniteTxEntry txEntry : m.writes()) {
- if (txEntry.op() == TRANSFORM)
- req.addDhtVersion(txEntry.txKey(), null);
- }
-
- // Must lock near entries separately.
- if (m.near()) {
- try {
- tx.optimisticLockEntries(req.writes());
-
- tx.userPrepare();
- }
- catch (IgniteCheckedException e) {
- onError(null, null, e);
- }
- }
-
- final MiniFuture fut = new MiniFuture(m, mappings);
-
- req.miniId(fut.futureId());
-
- add(fut); // Append new future.
-
- // If this is the primary node for the keys.
- if (n.isLocal()) {
- // At this point, if any new node joined, then it is
- // waiting for this transaction to complete, so
- // partition reassignments are not possible here.
- IgniteInternalFuture<GridNearTxPrepareResponse> prepFut = cctx.tm().txHandler().prepareTx(n.id(), tx, req);
-
- prepFut.listen(new CI1<IgniteInternalFuture<GridNearTxPrepareResponse>>() {
- @Override public void apply(IgniteInternalFuture<GridNearTxPrepareResponse> prepFut) {
- try {
- fut.onResult(n.id(), prepFut.get());
- }
- catch (IgniteCheckedException e) {
- fut.onResult(e);
- }
- }
- });
- }
- else {
- try {
- cctx.io().send(n, req, tx.ioPolicy());
- }
- catch (IgniteCheckedException e) {
- // Fail the whole thing.
- fut.onResult(e);
- }
- }
- }
-
- /**
- * @param entry Transaction entry.
- * @param topVer Topology version.
- * @param cur Current mapping.
- * @throws IgniteCheckedException If transaction is group-lock and local node is not primary for key.
- * @return Mapping.
- */
- private GridDistributedTxMapping map(
- IgniteTxEntry entry,
- AffinityTopologyVersion topVer,
- GridDistributedTxMapping cur,
- boolean waitLock
- ) throws IgniteCheckedException {
- GridCacheContext cacheCtx = entry.context();
-
- List<ClusterNode> nodes = cacheCtx.affinity().nodes(entry.key(), topVer);
-
- txMapping.addMapping(nodes);
-
- ClusterNode primary = F.first(nodes);
-
- assert primary != null;
-
- if (log.isDebugEnabled()) {
- log.debug("Mapped key to primary node [key=" + entry.key() +
- ", part=" + cacheCtx.affinity().partition(entry.key()) +
- ", primary=" + U.toShortString(primary) + ", topVer=" + topVer + ']');
- }
-
- // Must re-initialize cached entry while holding topology lock.
- if (cacheCtx.isNear())
- entry.cached(cacheCtx.nearTx().entryExx(entry.key(), topVer));
- else if (!cacheCtx.isLocal())
- entry.cached(cacheCtx.colocated().entryExx(entry.key(), topVer, true));
- else
- entry.cached(cacheCtx.local().entryEx(entry.key(), topVer));
-
- if (cacheCtx.isNear() || cacheCtx.isLocal()) {
- if (waitLock && entry.explicitVersion() == null)
- lockKeys.add(entry.txKey());
- }
-
- if (cur == null || !cur.node().id().equals(primary.id()) || cur.near() != cacheCtx.isNear()) {
- cur = new GridDistributedTxMapping(primary);
-
- // Initialize near flag right away.
- cur.near(cacheCtx.isNear());
- }
-
- cur.add(entry);
-
- if (entry.explicitVersion() != null) {
- tx.markExplicit(primary.id());
-
- cur.markExplicitLock();
- }
-
- entry.nodeId(primary.id());
-
- if (cacheCtx.isNear()) {
- while (true) {
- try {
- GridNearCacheEntry cached = (GridNearCacheEntry)entry.cached();
-
- cached.dhtNodeId(tx.xidVersion(), primary.id());
-
- break;
- }
- catch (GridCacheEntryRemovedException ignore) {
- entry.cached(cacheCtx.near().entryEx(entry.key()));
- }
- }
- }
-
- return cur;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() {
- @Override public String apply(IgniteInternalFuture<?> f) {
- return "[node=" + ((MiniFuture)f).node().id() +
- ", loc=" + ((MiniFuture)f).node().isLocal() +
- ", done=" + f.isDone() + "]";
- }
- });
-
- return S.toString(GridNearOptimisticTxPrepareFuture.class, this,
- "futs", futs,
- "super", super.toString());
- }
-
- /**
- *
- */
- private class MiniFuture extends GridFutureAdapter<IgniteInternalTx> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final IgniteUuid futId = IgniteUuid.randomUuid();
-
- /** Keys. */
- @GridToStringInclude
- private GridDistributedTxMapping m;
-
- /** Flag to signal some result being processed. */
- private AtomicBoolean rcvRes = new AtomicBoolean(false);
-
- /** Mappings to proceed prepare. */
- private ConcurrentLinkedDeque8<GridDistributedTxMapping> mappings;
-
- /**
- * @param m Mapping.
- * @param mappings Queue of mappings to proceed with.
- */
- MiniFuture(
- GridDistributedTxMapping m,
- ConcurrentLinkedDeque8<GridDistributedTxMapping> mappings
- ) {
- this.m = m;
- this.mappings = mappings;
- }
-
- /**
- * @return Future ID.
- */
- IgniteUuid futureId() {
- return futId;
- }
-
- /**
- * @return Node ID.
- */
- public ClusterNode node() {
- return m.node();
- }
-
- /**
- * @return Keys.
- */
- public GridDistributedTxMapping mapping() {
- return m;
- }
-
- /**
- * @param e Error.
- */
- void onResult(Throwable e) {
- if (rcvRes.compareAndSet(false, true)) {
- if (log.isDebugEnabled())
- log.debug("Failed to get future result [fut=" + this + ", err=" + e + ']');
-
- // Fail.
- onDone(e);
- }
- else
- U.warn(log, "Received error after another result has been processed [fut=" +
- GridNearOptimisticTxPrepareFuture.this + ", mini=" + this + ']', e);
- }
-
- /**
- * @param e Node failure.
- */
- void onResult(ClusterTopologyCheckedException e) {
- if (isDone())
- return;
-
- if (rcvRes.compareAndSet(false, true)) {
- if (log.isDebugEnabled())
- log.debug("Remote node left grid while sending or waiting for reply (will not retry): " + this);
-
- // Fail the whole future (make sure not to remap on different primary node
- // to prevent multiple lock coordinators).
- onError(null, null, e);
- }
- }
-
- /**
- * @param nodeId Failed node ID.
- * @param res Result callback.
- */
- void onResult(UUID nodeId, GridNearTxPrepareResponse res) {
- if (isDone())
- return;
-
- if (rcvRes.compareAndSet(false, true)) {
- if (res.error() != null) {
- // Fail the whole compound future.
- onError(nodeId, mappings, res.error());
- }
- else {
- onPrepareResponse(m, res);
-
- // Proceed prepare before finishing mini future.
- if (mappings != null)
- proceedPrepare(mappings);
-
- // Finish this mini future.
- onDone(tx);
- }
- }
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(MiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
deleted file mode 100644
index bce62c1..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
+++ /dev/null
@@ -1,347 +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.internal.processors.cache.distributed.near;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.cluster.*;
-import org.apache.ignite.internal.processors.affinity.*;
-import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.processors.cache.distributed.*;
-import org.apache.ignite.internal.processors.cache.distributed.dht.*;
-import org.apache.ignite.internal.processors.cache.transactions.*;
-import org.apache.ignite.internal.transactions.*;
-import org.apache.ignite.internal.util.future.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-
-import static org.apache.ignite.internal.processors.cache.GridCacheOperation.*;
-import static org.apache.ignite.transactions.TransactionState.*;
-
-/**
- *
- */
-public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureAdapter {
- /**
- * @param cctx Context.
- * @param tx Transaction.
- */
- public GridNearPessimisticTxPrepareFuture(GridCacheSharedContext cctx, GridNearTxLocal tx) {
- super(cctx, tx);
-
- assert tx.pessimistic() : tx;
-
- // Should wait for all mini futures completion before finishing tx.
- ignoreChildFailures(IgniteCheckedException.class);
- }
-
- /** {@inheritDoc} */
- @Override public Collection<? extends ClusterNode> nodes() {
- return F.viewReadOnly(futures(), new IgniteClosure<IgniteInternalFuture<?>, ClusterNode>() {
- @Nullable @Override public ClusterNode apply(IgniteInternalFuture<?> f) {
- return ((MiniFuture)f).node();
- }
- });
- }
-
- /** {@inheritDoc} */
- @Override public boolean onNodeLeft(UUID nodeId) {
- boolean found = false;
-
- for (IgniteInternalFuture<?> fut : futures()) {
- MiniFuture f = (MiniFuture)fut;
-
- if (f.node().id().equals(nodeId)) {
- f.onNodeLeft(new ClusterTopologyCheckedException("Remote node left grid: " + nodeId));
-
- found = true;
- }
- }
-
- return found;
- }
-
- /** {@inheritDoc} */
- @Override public void onResult(UUID nodeId, GridNearTxPrepareResponse res) {
- if (!isDone()) {
- for (IgniteInternalFuture<IgniteInternalTx> fut : pending()) {
- MiniFuture f = (MiniFuture)fut;
-
- if (f.futureId().equals(res.miniId())) {
- assert f.node().id().equals(nodeId);
-
- if (log.isDebugEnabled())
- log.debug("Remote node left grid while sending or waiting for reply (will not retry): " + f);
-
- f.onResult(res);
- }
- }
- }
- }
- /** {@inheritDoc} */
- @Override public void prepare() {
- if (!tx.state(PREPARING)) {
- if (tx.setRollbackOnly()) {
- if (tx.timedOut())
- onDone(new IgniteTxTimeoutCheckedException("Transaction timed out and was rolled back: " + tx));
- else
- onDone(new IgniteCheckedException("Invalid transaction state for prepare " +
- "[state=" + tx.state() + ", tx=" + this + ']'));
- }
- else
- onDone(new IgniteTxRollbackCheckedException("Invalid transaction state for prepare " +
- "[state=" + tx.state() + ", tx=" + this + ']'));
-
- return;
- }
-
- try {
- tx.userPrepare();
-
- cctx.mvcc().addFuture(this);
-
- preparePessimistic();
- }
- catch (IgniteCheckedException e) {
- onDone(e);
- }
- }
-
- /**
- *
- */
- private void preparePessimistic() {
- Map<IgniteBiTuple<ClusterNode, Boolean>, GridDistributedTxMapping> mappings = new HashMap<>();
-
- AffinityTopologyVersion topVer = tx.topologyVersion();
-
- txMapping = new GridDhtTxMapping();
-
- for (IgniteTxEntry txEntry : tx.allEntries()) {
- GridCacheContext cacheCtx = txEntry.context();
-
- List<ClusterNode> nodes = cacheCtx.affinity().nodes(txEntry.key(), topVer);
-
- ClusterNode primary = F.first(nodes);
-
- boolean near = cacheCtx.isNear();
-
- IgniteBiTuple<ClusterNode, Boolean> key = F.t(primary, near);
-
- GridDistributedTxMapping nodeMapping = mappings.get(key);
-
- if (nodeMapping == null) {
- nodeMapping = new GridDistributedTxMapping(primary);
-
- nodeMapping.near(cacheCtx.isNear());
-
- mappings.put(key, nodeMapping);
- }
-
- txEntry.nodeId(primary.id());
-
- nodeMapping.add(txEntry);
-
- txMapping.addMapping(nodes);
- }
-
- tx.transactionNodes(txMapping.transactionNodes());
-
- checkOnePhase();
-
- for (final GridDistributedTxMapping m : mappings.values()) {
- final ClusterNode node = m.node();
-
- GridNearTxPrepareRequest req = new GridNearTxPrepareRequest(
- futId,
- tx.topologyVersion(),
- tx,
- m.reads(),
- m.writes(),
- m.near(),
- txMapping.transactionNodes(),
- true,
- txMapping.transactionNodes().get(node.id()),
- tx.onePhaseCommit(),
- tx.needReturnValue() && tx.implicit(),
- tx.implicitSingle(),
- m.explicitLock(),
- tx.subjectId(),
- tx.taskNameHash());
-
- for (IgniteTxEntry txEntry : m.writes()) {
- if (txEntry.op() == TRANSFORM)
- req.addDhtVersion(txEntry.txKey(), null);
- }
-
- final MiniFuture fut = new MiniFuture(m);
-
- req.miniId(fut.futureId());
-
- add(fut);
-
- if (node.isLocal()) {
- IgniteInternalFuture<GridNearTxPrepareResponse> prepFut = cctx.tm().txHandler().prepareTx(node.id(),
- tx,
- req);
-
- prepFut.listen(new CI1<IgniteInternalFuture<GridNearTxPrepareResponse>>() {
- @Override public void apply(IgniteInternalFuture<GridNearTxPrepareResponse> prepFut) {
- try {
- fut.onResult(prepFut.get());
- }
- catch (IgniteCheckedException e) {
- fut.onError(e);
- }
- }
- });
- }
- else {
- try {
- cctx.io().send(node, req, tx.ioPolicy());
- }
- catch (ClusterTopologyCheckedException e) {
- fut.onNodeLeft(e);
- }
- catch (IgniteCheckedException e) {
- fut.onError(e);
- }
- }
- }
-
- markInitialized();
- }
-
- /** {@inheritDoc} */
- @Override public boolean onDone(@Nullable IgniteInternalTx res, @Nullable Throwable err) {
- if (err != null)
- this.err.compareAndSet(null, err);
-
- err = this.err.get();
-
- if (err == null)
- tx.state(PREPARED);
-
- if (super.onDone(tx, err)) {
- cctx.mvcc().removeFuture(this);
-
- return true;
- }
-
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() {
- @Override public String apply(IgniteInternalFuture<?> f) {
- return "[node=" + ((MiniFuture)f).node().id() +
- ", loc=" + ((MiniFuture)f).node().isLocal() +
- ", done=" + f.isDone() + "]";
- }
- });
-
- return S.toString(GridNearPessimisticTxPrepareFuture.class, this,
- "futs", futs,
- "super", super.toString());
- }
-
- /**
- *
- */
- private class MiniFuture extends GridFutureAdapter<IgniteInternalTx> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final IgniteUuid futId = IgniteUuid.randomUuid();
-
- /** */
- private GridDistributedTxMapping m;
-
- /**
- * @param m Mapping.
- */
- MiniFuture(GridDistributedTxMapping m) {
- this.m = m;
- }
-
- /**
- * @return Future ID.
- */
- IgniteUuid futureId() {
- return futId;
- }
-
- /**
- * @return Node ID.
- */
- public ClusterNode node() {
- return m.node();
- }
-
- /**
- * @param res Response.
- */
- void onResult(GridNearTxPrepareResponse res) {
- if (res.error() != null)
- onError(res.error());
- else {
- onPrepareResponse(m, res);
-
- onDone(tx);
- }
- }
-
- /**
- * @param e Error.
- */
- void onNodeLeft(ClusterTopologyCheckedException e) {
- onError(e);
- }
-
- /**
- * @param e Error.
- */
- void onError(Throwable e) {
- if (isDone()) {
- U.warn(log, "Received error when future is done [fut=" + this + ", err=" + e + ", tx=" + tx + ']');
-
- return;
- }
-
- if (log.isDebugEnabled())
- log.debug("Error on tx prepare [fut=" + this + ", err=" + e + ", tx=" + tx + ']');
-
- if (err.compareAndSet(null, e))
- tx.setRollbackOnly();
-
- onDone(e);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(MiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index df7a65f..581c7e0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -301,10 +301,14 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
req.isInvalidate(),
req.timeout(),
req.txSize(),
+ req.groupLockKey(),
req.subjectId(),
req.taskNameHash()
);
+ if (req.groupLock())
+ tx.groupLockKey(txKey);
+
tx = ctx.tm().onCreated(null, tx);
if (tx == null || !ctx.tm().onStarted(tx))
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
index b44f821..7b0b811 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
@@ -97,7 +97,7 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
@Nullable UUID subjId,
int taskNameHash) {
super(xidVer, futId, null, threadId, commit, invalidate, sys, plc, syncCommit, syncRollback, baseVer,
- committedVers, rolledbackVers, txSize);
+ committedVers, rolledbackVers, txSize, null);
this.explicitLock = explicitLock;
this.storeEnabled = storeEnabled;
@@ -170,37 +170,37 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
}
switch (writer.state()) {
- case 19:
+ case 20:
if (!writer.writeBoolean("explicitLock", explicitLock))
return false;
writer.incrementState();
- case 20:
+ case 21:
if (!writer.writeIgniteUuid("miniId", miniId))
return false;
writer.incrementState();
- case 21:
+ case 22:
if (!writer.writeBoolean("storeEnabled", storeEnabled))
return false;
writer.incrementState();
- case 22:
+ case 23:
if (!writer.writeUuid("subjId", subjId))
return false;
writer.incrementState();
- case 23:
+ case 24:
if (!writer.writeInt("taskNameHash", taskNameHash))
return false;
writer.incrementState();
- case 24:
+ case 25:
if (!writer.writeMessage("topVer", topVer))
return false;
@@ -222,7 +222,7 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
return false;
switch (reader.state()) {
- case 19:
+ case 20:
explicitLock = reader.readBoolean("explicitLock");
if (!reader.isLastRead())
@@ -230,7 +230,7 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 20:
+ case 21:
miniId = reader.readIgniteUuid("miniId");
if (!reader.isLastRead())
@@ -238,7 +238,7 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 21:
+ case 22:
storeEnabled = reader.readBoolean("storeEnabled");
if (!reader.isLastRead())
@@ -246,7 +246,7 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 22:
+ case 23:
subjId = reader.readUuid("subjId");
if (!reader.isLastRead())
@@ -254,7 +254,7 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 23:
+ case 24:
taskNameHash = reader.readInt("taskNameHash");
if (!reader.isLastRead())
@@ -262,7 +262,7 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 24:
+ case 25:
topVer = reader.readMessage("topVer");
if (!reader.isLastRead())
@@ -282,7 +282,7 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishRequest {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 25;
+ return 26;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index 5c426ed..c665354 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -61,7 +61,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
/** Future. */
@GridToStringExclude
- private final AtomicReference<IgniteInternalFuture<?>> prepFut = new AtomicReference<>();
+ private final AtomicReference<IgniteInternalFuture<IgniteInternalTx>> prepFut =
+ new AtomicReference<>();
/** */
@GridToStringExclude
@@ -102,6 +103,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
* @param timeout Timeout.
* @param storeEnabled Store enabled flag.
* @param txSize Transaction size.
+ * @param grpLockKey Group lock key if this is a group lock transaction.
+ * @param partLock {@code True} if this is a group-lock transaction and the whole partition should be locked.
* @param subjId Subject ID.
* @param taskNameHash Task name hash code.
*/
@@ -116,6 +119,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
long timeout,
boolean storeEnabled,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
+ boolean partLock,
@Nullable UUID subjId,
int taskNameHash
) {
@@ -133,6 +138,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
false,
storeEnabled,
txSize,
+ grpLockKey,
+ partLock,
subjId,
taskNameHash);
@@ -266,6 +273,9 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
/** {@inheritDoc} */
@Override public Collection<IgniteTxEntry> optimisticLockEntries() {
+ if (groupLock())
+ return super.optimisticLockEntries();
+
return optimisticLockEntries;
}
@@ -407,6 +417,13 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
}
}
+ /** {@inheritDoc} */
+ @Override protected void addGroupTxMapping(Collection<IgniteTxKey> keys) {
+ super.addGroupTxMapping(keys);
+
+ addKeyMapping(cctx.localNode(), keys);
+ }
+
/**
* Adds key mapping to dht mapping.
*
@@ -546,7 +563,9 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
Collection<GridCacheVersion> committedVers,
Collection<GridCacheVersion> rolledbackVers)
{
- Collection<IgniteTxEntry> entries = F.concat(false, mapping.reads(), mapping.writes());
+ Collection<IgniteTxEntry> entries = groupLock() ?
+ Collections.singletonList(groupLockEntry()) :
+ F.concat(false, mapping.reads(), mapping.writes());
for (IgniteTxEntry txEntry : entries) {
while (true) {
@@ -663,13 +682,12 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
}
/** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> prepareAsync() {
- GridNearTxPrepareFutureAdapter fut = (GridNearTxPrepareFutureAdapter)prepFut.get();
+ @Override public IgniteInternalFuture<IgniteInternalTx> prepareAsync() {
+ GridNearTxPrepareFuture fut = (GridNearTxPrepareFuture)prepFut.get();
if (fut == null) {
// Future must be created before any exception can be thrown.
- fut = optimistic() ? new GridNearOptimisticTxPrepareFuture(cctx, this) :
- new GridNearPessimisticTxPrepareFuture(cctx, this);
+ fut = new GridNearTxPrepareFuture<>(cctx, this);
if (!prepFut.compareAndSet(null, fut))
return prepFut.get();
@@ -680,7 +698,41 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
mapExplicitLocks();
- fut.prepare();
+ // For pessimistic mode we don't distribute prepare request and do not lock topology version
+ // as it was fixed on first lock.
+ if (pessimistic()) {
+ if (!state(PREPARING)) {
+ if (setRollbackOnly()) {
+ if (timedOut())
+ fut.onError(new IgniteTxTimeoutCheckedException("Transaction timed out and was " +
+ "rolled back: " + this));
+ else
+ fut.onError(new IgniteCheckedException("Invalid transaction state for prepare [state=" +
+ state() + ", tx=" + this + ']'));
+ }
+ else
+ fut.onError(new IgniteTxRollbackCheckedException("Invalid transaction state for prepare " +
+ "[state=" + state() + ", tx=" + this + ']'));
+
+ return fut;
+ }
+
+ try {
+ userPrepare();
+
+ // Make sure to add future before calling prepare.
+ cctx.mvcc().addFuture(fut);
+
+ fut.prepare();
+ }
+ catch (IgniteCheckedException e) {
+ fut.onError(e);
+ }
+ }
+ else {
+ // In optimistic mode we must wait for topology map update.
+ fut.prepare();
+ }
return fut;
}
@@ -700,10 +752,10 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
cctx.mvcc().addFuture(fut);
- IgniteInternalFuture<?> prepareFut = prepFut.get();
+ IgniteInternalFuture<IgniteInternalTx> prepareFut = prepFut.get();
- prepareFut.listen(new CI1<IgniteInternalFuture<?>>() {
- @Override public void apply(IgniteInternalFuture<?> f) {
+ prepareFut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
+ @Override public void apply(IgniteInternalFuture<IgniteInternalTx> f) {
GridNearTxFinishFuture fut0 = commitFut.get();
try {
@@ -747,7 +799,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
cctx.mvcc().addFuture(fut);
- IgniteInternalFuture<?> prepFut = this.prepFut.get();
+ IgniteInternalFuture<IgniteInternalTx> prepFut = this.prepFut.get();
if (prepFut == null || prepFut.isDone()) {
try {
@@ -771,8 +823,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
}
}
else {
- prepFut.listen(new CI1<IgniteInternalFuture<?>>() {
- @Override public void apply(IgniteInternalFuture<?> f) {
+ prepFut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
+ @Override public void apply(IgniteInternalFuture<IgniteInternalTx> f) {
try {
// Check for errors in prepare future.
f.get();
@@ -815,11 +867,12 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
* @return Future that will be completed when locks are acquired.
*/
@SuppressWarnings("TypeMayBeWeakened")
- public IgniteInternalFuture<GridNearTxPrepareResponse> prepareAsyncLocal(
+ public IgniteInternalFuture<IgniteInternalTx> prepareAsyncLocal(
@Nullable Collection<IgniteTxEntry> reads,
@Nullable Collection<IgniteTxEntry> writes,
Map<UUID, Collection<UUID>> txNodes, boolean last,
- Collection<UUID> lastBackups
+ Collection<UUID> lastBackups,
+ IgniteInClosure<GridNearTxPrepareResponse> completeCb
) {
if (state() != PREPARING) {
if (timedOut())
@@ -834,14 +887,15 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
init();
- GridDhtTxPrepareFuture fut = new GridDhtTxPrepareFuture(
+ GridDhtTxPrepareFuture fut = new GridDhtTxPrepareFuture<>(
cctx,
this,
IgniteUuid.randomUuid(),
Collections.<IgniteTxKey, GridCacheVersion>emptyMap(),
last,
needReturnValue() && implicit(),
- lastBackups);
+ lastBackups,
+ completeCb);
try {
// At this point all the entries passed in must be enlisted in transaction because this is an
@@ -880,7 +934,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
}
}
- return chainOnePhasePrepare(fut);
+ return fut;
}
/**
@@ -896,7 +950,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
if (pessimistic())
prepareAsync();
- IgniteInternalFuture<?> prep = prepFut.get();
+ IgniteInternalFuture<IgniteInternalTx> prep = prepFut.get();
// Do not create finish future if there are no remote nodes.
if (F.isEmpty(dhtMap) && F.isEmpty(nearMap)) {
@@ -932,8 +986,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
}
}
else
- prep.listen(new CI1<IgniteInternalFuture<?>>() {
- @Override public void apply(IgniteInternalFuture<?> f) {
+ prep.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
+ @Override public void apply(IgniteInternalFuture<IgniteInternalTx> f) {
try {
f.get(); // Check for errors of a parent future.
@@ -969,7 +1023,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
cctx.mvcc().addFuture(fut);
- IgniteInternalFuture<?> prep = prepFut.get();
+ IgniteInternalFuture<IgniteInternalTx> prep = prepFut.get();
if (prep == null || prep.isDone()) {
try {
@@ -985,8 +1039,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
fut.finish();
}
else
- prep.listen(new CI1<IgniteInternalFuture<?>>() {
- @Override public void apply(IgniteInternalFuture<?> f) {
+ prep.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
+ @Override public void apply(IgniteInternalFuture<IgniteInternalTx> f) {
try {
f.get(); // Check for errors of a parent future.
}
@@ -1179,7 +1233,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
- @Nullable @Override public IgniteInternalFuture<?> currentPrepareFuture() {
+ @Nullable @Override public IgniteInternalFuture<IgniteInternalTx> currentPrepareFuture() {
return prepFut.get();
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
new file mode 100644
index 0000000..f573187
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFuture.java
@@ -0,0 +1,1050 @@
+/*
+ * 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.distributed.near;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.cluster.*;
+import org.apache.ignite.internal.processors.affinity.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.processors.cache.distributed.*;
+import org.apache.ignite.internal.processors.cache.distributed.dht.*;
+import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.*;
+import org.apache.ignite.internal.processors.cache.transactions.*;
+import org.apache.ignite.internal.processors.cache.version.*;
+import org.apache.ignite.internal.transactions.*;
+import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.future.*;
+import org.apache.ignite.internal.util.lang.*;
+import org.apache.ignite.internal.util.tostring.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.transactions.*;
+import org.jetbrains.annotations.*;
+import org.jsr166.*;
+
+import javax.cache.expiry.*;
+import java.util.*;
+import java.util.concurrent.atomic.*;
+
+import static org.apache.ignite.internal.processors.cache.GridCacheOperation.*;
+import static org.apache.ignite.transactions.TransactionState.*;
+
+/**
+ *
+ */
+public final class GridNearTxPrepareFuture<K, V> extends GridCompoundIdentityFuture<IgniteInternalTx>
+ implements GridCacheMvccFuture<IgniteInternalTx> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Logger reference. */
+ private static final AtomicReference<IgniteLogger> logRef = new AtomicReference<>();
+
+ /** Logger. */
+ private static IgniteLogger log;
+
+ /** Context. */
+ private GridCacheSharedContext<K, V> cctx;
+
+ /** Future ID. */
+ private IgniteUuid futId;
+
+ /** Transaction. */
+ @GridToStringInclude
+ private GridNearTxLocal tx;
+
+ /** Error. */
+ @GridToStringExclude
+ private AtomicReference<Throwable> err = new AtomicReference<>(null);
+
+ /** Trackable flag. */
+ private boolean trackable = true;
+
+ /** Full information about transaction nodes mapping. */
+ private GridDhtTxMapping<K, V> txMapping;
+
+ /** */
+ private Collection<IgniteTxKey> lockKeys = new GridConcurrentHashSet<>();
+
+ /**
+ * @param cctx Context.
+ * @param tx Transaction.
+ */
+ public GridNearTxPrepareFuture(GridCacheSharedContext<K, V> cctx, final GridNearTxLocal tx) {
+ super(cctx.kernalContext(), new IgniteReducer<IgniteInternalTx, IgniteInternalTx>() {
+ @Override public boolean collect(IgniteInternalTx e) {
+ return true;
+ }
+
+ @Override public IgniteInternalTx reduce() {
+ // Nothing to aggregate.
+ return tx;
+ }
+ });
+
+ assert cctx != null;
+ assert tx != null;
+
+ this.cctx = cctx;
+ this.tx = tx;
+
+ futId = IgniteUuid.randomUuid();
+
+ if (log == null)
+ log = U.logger(cctx.kernalContext(), logRef, GridNearTxPrepareFuture.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteUuid futureId() {
+ return futId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCacheVersion version() {
+ return tx.xidVersion();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner) {
+ if (log.isDebugEnabled())
+ log.debug("Transaction future received owner changed callback: " + entry);
+
+ if (tx.optimistic()) {
+ if ((entry.context().isNear() || entry.context().isLocal()) && owner != null && tx.hasWriteKey(entry.txKey())) {
+ lockKeys.remove(entry.txKey());
+
+ // This will check for locks.
+ onDone();
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @return Involved nodes.
+ */
+ @Override public Collection<? extends ClusterNode> nodes() {
+ return
+ F.viewReadOnly(futures(), new IgniteClosure<IgniteInternalFuture<?>, ClusterNode>() {
+ @Nullable @Override public ClusterNode apply(IgniteInternalFuture<?> f) {
+ if (isMini(f))
+ return ((MiniFuture)f).node();
+
+ return cctx.discovery().localNode();
+ }
+ });
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean trackable() {
+ return trackable;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void markNotTrackable() {
+ trackable = false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean onNodeLeft(UUID nodeId) {
+ boolean found = false;
+
+ for (IgniteInternalFuture<?> fut : futures())
+ if (isMini(fut)) {
+ MiniFuture f = (MiniFuture)fut;
+
+ if (f.node().id().equals(nodeId)) {
+ f.onResult(new ClusterTopologyCheckedException("Remote node left grid: " + nodeId));
+
+ found = true;
+ }
+ }
+
+ return found;
+ }
+
+ /**
+ * @param nodeId Failed node ID.
+ * @param mappings Remaining mappings.
+ * @param e Error.
+ */
+ void onError(@Nullable UUID nodeId, @Nullable Iterable<GridDistributedTxMapping> mappings, Throwable e) {
+ if (err.compareAndSet(null, e)) {
+ boolean marked = tx.setRollbackOnly();
+
+ if (e instanceof IgniteTxOptimisticCheckedException) {
+ assert nodeId != null : "Missing node ID for optimistic failure exception: " + e;
+
+ tx.removeKeysMapping(nodeId, mappings);
+ }
+
+ if (e instanceof IgniteTxRollbackCheckedException) {
+ if (marked) {
+ try {
+ tx.rollback();
+ }
+ catch (IgniteCheckedException ex) {
+ U.error(log, "Failed to automatically rollback transaction: " + tx, ex);
+ }
+ }
+ }
+
+ onComplete();
+ }
+ }
+
+ /**
+ * @return {@code True} if all locks are owned.
+ */
+ private boolean checkLocks() {
+ boolean locked = lockKeys.isEmpty();
+
+ if (locked) {
+ if (log.isDebugEnabled())
+ log.debug("All locks are acquired for near prepare future: " + this);
+ }
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Still waiting for locks [fut=" + this + ", keys=" + lockKeys + ']');
+ }
+
+ return locked;
+ }
+
+ /**
+ * @param e Error.
+ */
+ void onError(Throwable e) {
+ onError(null, null, e);
+ }
+
+ /**
+ * @param nodeId Sender.
+ * @param res Result.
+ */
+ public void onResult(UUID nodeId, GridNearTxPrepareResponse res) {
+ if (!isDone()) {
+ for (IgniteInternalFuture<IgniteInternalTx> fut : pending()) {
+ if (isMini(fut)) {
+ MiniFuture f = (MiniFuture)fut;
+
+ if (f.futureId().equals(res.miniId())) {
+ assert f.node().id().equals(nodeId);
+
+ f.onResult(nodeId, res);
+ }
+ }
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean onDone(IgniteInternalTx t, Throwable err) {
+ // If locks were not acquired yet, delay completion.
+ if (isDone() || (err == null && !checkLocks()))
+ return false;
+
+ this.err.compareAndSet(null, err);
+
+ if (err == null)
+ tx.state(PREPARED);
+
+ if (super.onDone(tx, err)) {
+ // Don't forget to clean up.
+ cctx.mvcc().removeFuture(this);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * @param f Future.
+ * @return {@code True} if mini-future.
+ */
+ private boolean isMini(IgniteInternalFuture<?> f) {
+ return f.getClass().equals(MiniFuture.class);
+ }
+
+ /**
+ * Completeness callback.
+ */
+ private void onComplete() {
+ if (super.onDone(tx, err.get()))
+ // Don't forget to clean up.
+ cctx.mvcc().removeFuture(this);
+ }
+
+ /**
+ * Completes this future.
+ */
+ void complete() {
+ onComplete();
+ }
+
+ /**
+ * Waits for topology exchange future to be ready and then prepares user transaction.
+ */
+ public void prepare() {
+ if (tx.optimistic()) {
+ // Obtain the topology version to use.
+ AffinityTopologyVersion topVer = cctx.mvcc().lastExplicitLockTopologyVersion(Thread.currentThread().getId());
+
+ if (topVer != null) {
+ tx.topologyVersion(topVer);
+
+ prepare0();
+
+ return;
+ }
+
+ prepareOnTopology();
+
+ }
+ else
+ preparePessimistic();
+ }
+
+ /**
+ *
+ */
+ private void prepareOnTopology() {
+ GridDhtTopologyFuture topFut = topologyReadLock();
+
+ try {
+ if (topFut == null) {
+ assert isDone();
+
+ return;
+ }
+
+ if (topFut.isDone()) {
+ StringBuilder invalidCaches = new StringBuilder();
+ Boolean cacheInvalid = false;
+ for (GridCacheContext ctx : cctx.cacheContexts()) {
+ if (tx.activeCacheIds().contains(ctx.cacheId()) && !topFut.isCacheTopologyValid(ctx)) {
+ if (cacheInvalid)
+ invalidCaches.append(", ");
+
+ invalidCaches.append(U.maskName(ctx.name()));
+
+ cacheInvalid = true;
+ }
+ }
+
+ if (cacheInvalid) {
+ onDone(new IgniteCheckedException("Failed to perform cache operation (cache topology is not valid): " +
+ invalidCaches.toString()));
+
+ return;
+ }
+
+ tx.topologyVersion(topFut.topologyVersion());
+
+ prepare0();
+ }
+ else {
+ topFut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
+ @Override
+ public void apply(IgniteInternalFuture<AffinityTopologyVersion> t) {
+ cctx.kernalContext().closure().runLocalSafe(new GridPlainRunnable() {
+ @Override
+ public void run() {
+ prepareOnTopology();
+ }
+ });
+ }
+ });
+ }
+ }
+ finally {
+ topologyReadUnlock();
+ }
+ }
+
+ /**
+ * Acquires topology read lock.
+ *
+ * @return Topology ready future.
+ */
+ private GridDhtTopologyFuture topologyReadLock() {
+ if (tx.activeCacheIds().isEmpty())
+ return cctx.exchange().lastTopologyFuture();
+
+ GridCacheContext<K, V> nonLocCtx = null;
+
+ for (int cacheId : tx.activeCacheIds()) {
+ GridCacheContext<K, V> cacheCtx = cctx.cacheContext(cacheId);
+
+ if (!cacheCtx.isLocal()) {
+ nonLocCtx = cacheCtx;
+
+ break;
+ }
+ }
+
+ if (nonLocCtx == null)
+ return cctx.exchange().lastTopologyFuture();
+
+ nonLocCtx.topology().readLock();
+
+ if (nonLocCtx.topology().stopping()) {
+ onDone(new IgniteCheckedException("Failed to perform cache operation (cache is stopped): " +
+ nonLocCtx.name()));
+
+ return null;
+ }
+
+ return nonLocCtx.topology().topologyVersionFuture();
+ }
+
+ /**
+ * Releases topology read lock.
+ */
+ private void topologyReadUnlock() {
+ if (!tx.activeCacheIds().isEmpty()) {
+ GridCacheContext<K, V> nonLocalCtx = null;
+
+ for (int cacheId : tx.activeCacheIds()) {
+ GridCacheContext<K, V> cacheCtx = cctx.cacheContext(cacheId);
+
+ if (!cacheCtx.isLocal()) {
+ nonLocalCtx = cacheCtx;
+
+ break;
+ }
+ }
+
+ if (nonLocalCtx != null)
+ nonLocalCtx.topology().readUnlock();
+ }
+ }
+
+ /**
+ * Initializes future.
+ */
+ private void prepare0() {
+ assert tx.optimistic();
+
+ try {
+ if (!tx.state(PREPARING)) {
+ if (tx.setRollbackOnly()) {
+ if (tx.timedOut())
+ onError(null, null, new IgniteTxTimeoutCheckedException("Transaction timed out and " +
+ "was rolled back: " + this));
+ else
+ onError(null, null, new IgniteCheckedException("Invalid transaction state for prepare " +
+ "[state=" + tx.state() + ", tx=" + this + ']'));
+ }
+ else
+ onError(null, null, new IgniteTxRollbackCheckedException("Invalid transaction state for " +
+ "prepare [state=" + tx.state() + ", tx=" + this + ']'));
+
+ return;
+ }
+
+ // Make sure to add future before calling prepare.
+ cctx.mvcc().addFuture(this);
+
+ prepare(
+ tx.optimistic() && tx.serializable() ? tx.readEntries() : Collections.<IgniteTxEntry>emptyList(),
+ tx.writeEntries());
+
+ markInitialized();
+ }
+ catch (TransactionTimeoutException | TransactionOptimisticException e) {
+ onError(cctx.localNodeId(), null, e);
+ }
+ catch (IgniteCheckedException e) {
+ onDone(e);
+ }
+ }
+
+ /**
+ * @param reads Read entries.
+ * @param writes Write entries.
+ * @throws IgniteCheckedException If transaction is group-lock and some key was mapped to to the local node.
+ */
+ private void prepare(
+ Iterable<IgniteTxEntry> reads,
+ Iterable<IgniteTxEntry> writes
+ ) throws IgniteCheckedException {
+ assert tx.optimistic();
+
+ AffinityTopologyVersion topVer = tx.topologyVersion();
+
+ assert topVer.topologyVersion() > 0;
+
+ txMapping = new GridDhtTxMapping<>();
+
+ ConcurrentLinkedDeque8<GridDistributedTxMapping> mappings =
+ new ConcurrentLinkedDeque8<>();
+
+ if (!F.isEmpty(reads) || !F.isEmpty(writes)) {
+ for (int cacheId : tx.activeCacheIds()) {
+ GridCacheContext<K, V> cacheCtx = cctx.cacheContext(cacheId);
+
+ if (CU.affinityNodes(cacheCtx, topVer).isEmpty()) {
+ onDone(new ClusterTopologyCheckedException("Failed to map keys for cache (all " +
+ "partition nodes left the grid): " + cacheCtx.name()));
+
+ return;
+ }
+ }
+ }
+
+ // Assign keys to primary nodes.
+ GridDistributedTxMapping cur = null;
+
+ for (IgniteTxEntry read : reads) {
+ GridDistributedTxMapping updated = map(read, topVer, cur, false);
+
+ if (cur != updated) {
+ mappings.offer(updated);
+
+ if (updated.node().isLocal()) {
+ if (read.context().isNear())
+ tx.nearLocallyMapped(true);
+ else if (read.context().isColocated())
+ tx.colocatedLocallyMapped(true);
+ }
+
+ cur = updated;
+ }
+ }
+
+ for (IgniteTxEntry write : writes) {
+ GridDistributedTxMapping updated = map(write, topVer, cur, true);
+
+ if (cur != updated) {
+ mappings.offer(updated);
+
+ if (updated.node().isLocal()) {
+ if (write.context().isNear())
+ tx.nearLocallyMapped(true);
+ else if (write.context().isColocated())
+ tx.colocatedLocallyMapped(true);
+ }
+
+ cur = updated;
+ }
+ }
+
+ if (isDone()) {
+ if (log.isDebugEnabled())
+ log.debug("Abandoning (re)map because future is done: " + this);
+
+ return;
+ }
+
+ tx.addEntryMapping(mappings);
+
+ cctx.mvcc().recheckPendingLocks();
+
+ txMapping.initLast(mappings);
+
+ tx.transactionNodes(txMapping.transactionNodes());
+
+ checkOnePhase();
+
+ proceedPrepare(mappings);
+ }
+
+ /**
+ *
+ */
+ private void preparePessimistic() {
+ Map<IgniteBiTuple<ClusterNode, Boolean>, GridDistributedTxMapping> mappings = new HashMap<>();
+
+ AffinityTopologyVersion topVer = tx.topologyVersion();
+
+ txMapping = new GridDhtTxMapping<>();
+
+ for (IgniteTxEntry txEntry : tx.allEntries()) {
+ GridCacheContext cacheCtx = txEntry.context();
+
+ List<ClusterNode> nodes = cacheCtx.affinity().nodes(txEntry.key(), topVer);
+
+ ClusterNode primary = F.first(nodes);
+
+ boolean near = cacheCtx.isNear();
+
+ IgniteBiTuple<ClusterNode, Boolean> key = F.t(primary, near);
+
+ GridDistributedTxMapping nodeMapping = mappings.get(key);
+
+ if (nodeMapping == null) {
+ nodeMapping = new GridDistributedTxMapping(primary);
+
+ nodeMapping.near(cacheCtx.isNear());
+
+ mappings.put(key, nodeMapping);
+ }
+
+ txEntry.nodeId(primary.id());
+
+ nodeMapping.add(txEntry);
+
+ txMapping.addMapping(nodes);
+ }
+
+ tx.transactionNodes(txMapping.transactionNodes());
+
+ checkOnePhase();
+
+ for (final GridDistributedTxMapping m : mappings.values()) {
+ final ClusterNode node = m.node();
+
+ GridNearTxPrepareRequest req = new GridNearTxPrepareRequest(
+ futId,
+ tx.topologyVersion(),
+ tx,
+ m.reads(),
+ m.writes(),
+ /*grp lock key*/null,
+ /*part lock*/false,
+ m.near(),
+ txMapping.transactionNodes(),
+ true,
+ txMapping.transactionNodes().get(node.id()),
+ tx.onePhaseCommit(),
+ tx.needReturnValue() && tx.implicit(),
+ tx.implicitSingle(),
+ m.explicitLock(),
+ tx.subjectId(),
+ tx.taskNameHash());
+
+ for (IgniteTxEntry txEntry : m.writes()) {
+ if (txEntry.op() == TRANSFORM)
+ req.addDhtVersion(txEntry.txKey(), null);
+ }
+
+ final MiniFuture fut = new MiniFuture(m, null);
+
+ req.miniId(fut.futureId());
+
+ add(fut);
+
+ if (node.isLocal()) {
+ cctx.tm().txHandler().prepareTx(node.id(), tx, req, new CI1<GridNearTxPrepareResponse>() {
+ @Override public void apply(GridNearTxPrepareResponse res) {
+ fut.onResult(node.id(), res);
+ }
+ });
+ }
+ else {
+ try {
+ cctx.io().send(node, req, tx.ioPolicy());
+ }
+ catch (IgniteCheckedException e) {
+ // Fail the whole thing.
+ fut.onResult(e);
+ }
+ }
+ }
+
+ markInitialized();
+ }
+
+ /**
+ * Checks if mapped transaction can be committed on one phase.
+ * One-phase commit can be done if transaction maps to one primary node and not more than one backup.
+ */
+ private void checkOnePhase() {
+ if (tx.storeUsed())
+ return;
+
+ Map<UUID, Collection<UUID>> map = txMapping.transactionNodes();
+
+ if (map.size() == 1) {
+ Map.Entry<UUID, Collection<UUID>> entry = F.firstEntry(map);
+
+ assert entry != null;
+
+ Collection<UUID> backups = entry.getValue();
+
+ if (backups.size() <= 1)
+ tx.onePhaseCommit(true);
+ }
+ }
+
+ /**
+ * Continues prepare after previous mapping successfully finished.
+ *
+ * @param mappings Queue of mappings.
+ */
+ private void proceedPrepare(final ConcurrentLinkedDeque8<GridDistributedTxMapping> mappings) {
+ if (isDone())
+ return;
+
+ final GridDistributedTxMapping m = mappings.poll();
+
+ if (m == null)
+ return;
+
+ assert !m.empty();
+
+ final ClusterNode n = m.node();
+
+ GridNearTxPrepareRequest req = new GridNearTxPrepareRequest(
+ futId,
+ tx.topologyVersion(),
+ tx,
+ tx.optimistic() && tx.serializable() ? m.reads() : null,
+ m.writes(),
+ tx.groupLockKey(),
+ tx.partitionLock(),
+ m.near(),
+ txMapping.transactionNodes(),
+ m.last(),
+ m.lastBackups(),
+ tx.onePhaseCommit(),
+ tx.needReturnValue() && tx.implicit(),
+ tx.implicitSingle(),
+ m.explicitLock(),
+ tx.subjectId(),
+ tx.taskNameHash());
+
+ for (IgniteTxEntry txEntry : m.writes()) {
+ if (txEntry.op() == TRANSFORM)
+ req.addDhtVersion(txEntry.txKey(), null);
+ }
+
+ // Must lock near entries separately.
+ if (m.near()) {
+ try {
+ tx.optimisticLockEntries(req.writes());
+
+ tx.userPrepare();
+ }
+ catch (IgniteCheckedException e) {
+ onError(null, null, e);
+ }
+ }
+
+ final MiniFuture fut = new MiniFuture(m, mappings);
+
+ req.miniId(fut.futureId());
+
+ add(fut); // Append new future.
+
+ // If this is the primary node for the keys.
+ if (n.isLocal()) {
+ // At this point, if any new node joined, then it is
+ // waiting for this transaction to complete, so
+ // partition reassignments are not possible here.
+ cctx.tm().txHandler().prepareTx(n.id(), tx, req, new CI1<GridNearTxPrepareResponse>() {
+ @Override public void apply(GridNearTxPrepareResponse res) {
+ fut.onResult(n.id(), res);
+ }
+ });
+ }
+ else {
+ assert !tx.groupLock() : "Got group lock transaction that is mapped on remote node [tx=" + tx +
+ ", nodeId=" + n.id() + ']';
+
+ try {
+ cctx.io().send(n, req, tx.ioPolicy());
+ }
+ catch (IgniteCheckedException e) {
+ // Fail the whole thing.
+ fut.onResult(e);
+ }
+ }
+ }
+
+ /**
+ * @param entry Transaction entry.
+ * @param topVer Topology version.
+ * @param cur Current mapping.
+ * @throws IgniteCheckedException If transaction is group-lock and local node is not primary for key.
+ * @return Mapping.
+ */
+ private GridDistributedTxMapping map(
+ IgniteTxEntry entry,
+ AffinityTopologyVersion topVer,
+ GridDistributedTxMapping cur,
+ boolean waitLock
+ ) throws IgniteCheckedException {
+ GridCacheContext cacheCtx = entry.context();
+
+ List<ClusterNode> nodes = cacheCtx.affinity().nodes(entry.key(), topVer);
+
+ txMapping.addMapping(nodes);
+
+ ClusterNode primary = F.first(nodes);
+
+ assert primary != null;
+
+ if (log.isDebugEnabled()) {
+ log.debug("Mapped key to primary node [key=" + entry.key() +
+ ", part=" + cacheCtx.affinity().partition(entry.key()) +
+ ", primary=" + U.toShortString(primary) + ", topVer=" + topVer + ']');
+ }
+
+ if (tx.groupLock() && !primary.isLocal())
+ throw new IgniteCheckedException("Failed to prepare group lock transaction (local node is not primary for " +
+ " key)[key=" + entry.key() + ", primaryNodeId=" + primary.id() + ']');
+
+ // Must re-initialize cached entry while holding topology lock.
+ if (cacheCtx.isNear())
+ entry.cached(cacheCtx.nearTx().entryExx(entry.key(), topVer));
+ else if (!cacheCtx.isLocal())
+ entry.cached(cacheCtx.colocated().entryExx(entry.key(), topVer, true));
+ else
+ entry.cached(cacheCtx.local().entryEx(entry.key(), topVer));
+
+ if (cacheCtx.isNear() || cacheCtx.isLocal()) {
+ if (waitLock && entry.explicitVersion() == null) {
+ if (!tx.groupLock() || tx.groupLockKey().equals(entry.txKey()))
+ lockKeys.add(entry.txKey());
+ }
+ }
+
+ if (cur == null || !cur.node().id().equals(primary.id()) || cur.near() != cacheCtx.isNear()) {
+ cur = new GridDistributedTxMapping(primary);
+
+ // Initialize near flag right away.
+ cur.near(cacheCtx.isNear());
+ }
+
+ cur.add(entry);
+
+ if (entry.explicitVersion() != null) {
+ tx.markExplicit(primary.id());
+
+ cur.markExplicitLock();
+ }
+
+ entry.nodeId(primary.id());
+
+ if (cacheCtx.isNear()) {
+ while (true) {
+ try {
+ GridNearCacheEntry cached = (GridNearCacheEntry)entry.cached();
+
+ cached.dhtNodeId(tx.xidVersion(), primary.id());
+
+ break;
+ }
+ catch (GridCacheEntryRemovedException ignore) {
+ entry.cached(cacheCtx.near().entryEx(entry.key()));
+ }
+ }
+ }
+
+ return cur;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(GridNearTxPrepareFuture.class, this, super.toString());
+ }
+
+ /**
+ * Mini-future for get operations. Mini-futures are only waiting on a single
+ * node as opposed to multiple nodes.
+ */
+ private class MiniFuture extends GridFutureAdapter<IgniteInternalTx> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final IgniteUuid futId = IgniteUuid.randomUuid();
+
+ /** Keys. */
+ @GridToStringInclude
+ private GridDistributedTxMapping m;
+
+ /** Flag to signal some result being processed. */
+ private AtomicBoolean rcvRes = new AtomicBoolean(false);
+
+ /** Mappings to proceed prepare. */
+ private ConcurrentLinkedDeque8<GridDistributedTxMapping> mappings;
+
+ /**
+ * @param m Mapping.
+ * @param mappings Queue of mappings to proceed with.
+ */
+ MiniFuture(
+ GridDistributedTxMapping m,
+ ConcurrentLinkedDeque8<GridDistributedTxMapping> mappings
+ ) {
+ this.m = m;
+ this.mappings = mappings;
+ }
+
+ /**
+ * @return Future ID.
+ */
+ IgniteUuid futureId() {
+ return futId;
+ }
+
+ /**
+ * @return Node ID.
+ */
+ public ClusterNode node() {
+ return m.node();
+ }
+
+ /**
+ * @return Keys.
+ */
+ public GridDistributedTxMapping mapping() {
+ return m;
+ }
+
+ /**
+ * @param e Error.
+ */
+ void onResult(Throwable e) {
+ if (rcvRes.compareAndSet(false, true)) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to get future result [fut=" + this + ", err=" + e + ']');
+
+ // Fail.
+ onDone(e);
+ }
+ else
+ U.warn(log, "Received error after another result has been processed [fut=" +
+ GridNearTxPrepareFuture.this + ", mini=" + this + ']', e);
+ }
+
+ /**
+ * @param e Node failure.
+ */
+ void onResult(ClusterTopologyCheckedException e) {
+ if (isDone())
+ return;
+
+ if (rcvRes.compareAndSet(false, true)) {
+ if (log.isDebugEnabled())
+ log.debug("Remote node left grid while sending or waiting for reply (will not retry): " + this);
+
+ // Fail the whole future (make sure not to remap on different primary node
+ // to prevent multiple lock coordinators).
+ onError(null, null, e);
+ }
+ }
+
+ /**
+ * @param nodeId Failed node ID.
+ * @param res Result callback.
+ */
+ void onResult(UUID nodeId, GridNearTxPrepareResponse res) {
+ if (isDone())
+ return;
+
+ if (rcvRes.compareAndSet(false, true)) {
+ if (res.error() != null) {
+ // Fail the whole compound future.
+ onError(nodeId, mappings, res.error());
+ }
+ else {
+ assert F.isEmpty(res.invalidPartitions());
+
+ for (Map.Entry<IgniteTxKey, CacheVersionedValue> entry : res.ownedValues().entrySet()) {
+ IgniteTxEntry txEntry = tx.entry(entry.getKey());
+
+ assert txEntry != null;
+
+ GridCacheContext cacheCtx = txEntry.context();
+
+ while (true) {
+ try {
+ if (cacheCtx.isNear()) {
+ GridNearCacheEntry nearEntry = (GridNearCacheEntry)txEntry.cached();
+
+ CacheVersionedValue tup = entry.getValue();
+
+ nearEntry.resetFromPrimary(tup.value(), tx.xidVersion(),
+ tup.version(), m.node().id(), tx.topologyVersion());
+ }
+ else if (txEntry.cached().detached()) {
+ GridDhtDetachedCacheEntry detachedEntry = (GridDhtDetachedCacheEntry)txEntry.cached();
+
+ CacheVersionedValue tup = entry.getValue();
+
+ detachedEntry.resetFromPrimary(tup.value(), tx.xidVersion());
+ }
+
+ break;
+ }
+ catch (GridCacheEntryRemovedException ignored) {
+ // Retry.
+ }
+ catch (IgniteCheckedException e) {
+ // Fail the whole compound future.
+ onError(nodeId, mappings, e);
+
+ return;
+ }
+ }
+ }
+
+ tx.implicitSingleResult(res.returnValue());
+
+ for (IgniteTxKey key : res.filterFailedKeys()) {
+ IgniteTxEntry txEntry = tx.entry(key);
+
+ assert txEntry != null : "Missing tx entry for write key: " + key;
+
+ txEntry.op(NOOP);
+
+ assert txEntry.context() != null;
+
+ ExpiryPolicy expiry = txEntry.context().expiryForTxEntry(txEntry);
+
+ if (expiry != null)
+ txEntry.ttl(CU.toTtl(expiry.getExpiryForAccess()));
+ }
+
+ if (!m.empty()) {
+ // Register DHT version.
+ tx.addDhtVersion(m.node().id(), res.dhtVersion());
+
+ m.dhtVersion(res.dhtVersion());
+
+ if (m.near())
+ tx.readyNearLocks(m, res.pending(), res.committedVersions(), res.rolledbackVersions());
+ }
+
+ // Proceed prepare before finishing mini future.
+ if (mappings != null)
+ proceedPrepare(mappings);
+
+ // Finish this mini future.
+ onDone(tx);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(MiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error());
+ }
+ }
+}
[6/8] incubator-ignite git commit: Revert "ignite-471: fixed NPE in
PortableMarshaller"
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
index 54b59b8..08fcaf6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
@@ -24,7 +24,6 @@ import org.apache.ignite.internal.processors.affinity.*;
import org.apache.ignite.internal.managers.communication.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.processors.cache.distributed.*;
-import org.apache.ignite.internal.processors.cache.distributed.near.*;
import org.apache.ignite.internal.processors.cache.transactions.*;
import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.util.*;
@@ -94,6 +93,8 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
* @param isolation Isolation.
* @param timeout Timeout.
* @param txSize Expected transaction size.
+ * @param grpLockKey Group lock key if this is a group-lock transaction.
+ * @param partLock If this is a group-lock transaction and the whole partition should be locked.
*/
protected GridDhtTxLocalAdapter(
GridCacheSharedContext cctx,
@@ -109,11 +110,13 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
boolean invalidate,
boolean storeEnabled,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
+ boolean partLock,
@Nullable UUID subjId,
int taskNameHash
) {
super(cctx, xidVer, implicit, implicitSingle, sys, plc, concurrency, isolation, timeout, invalidate,
- storeEnabled, txSize, subjId, taskNameHash);
+ storeEnabled, txSize, grpLockKey, partLock, subjId, taskNameHash);
assert cctx != null;
@@ -729,6 +732,68 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
}
/** {@inheritDoc} */
+ @Override protected void addGroupTxMapping(Collection<IgniteTxKey> keys) {
+ assert groupLock();
+
+ for (GridDistributedTxMapping mapping : dhtMap.values())
+ mapping.entries(Collections.unmodifiableCollection(txMap.values()), true);
+
+ // Here we know that affinity key for all given keys is our group lock key.
+ // Just add entries to dht mapping.
+ // Add near readers. If near cache is disabled on all nodes, do nothing.
+ Collection<UUID> backupIds = dhtMap.keySet();
+
+ Map<ClusterNode, List<GridDhtCacheEntry>> locNearMap = null;
+
+ for (IgniteTxKey key : keys) {
+ IgniteTxEntry txEntry = entry(key);
+
+ if (!txEntry.groupLockEntry() || txEntry.context().isNear())
+ continue;
+
+ assert txEntry.cached() instanceof GridDhtCacheEntry : "Invalid entry type: " + txEntry.cached();
+
+ while (true) {
+ try {
+ GridDhtCacheEntry entry = (GridDhtCacheEntry)txEntry.cached();
+
+ Collection<UUID> readers = entry.readers();
+
+ if (!F.isEmpty(readers)) {
+ Collection<ClusterNode> nearNodes = cctx.discovery().nodes(readers, F0.notEqualTo(nearNodeId()),
+ F.notIn(backupIds));
+
+ if (log.isDebugEnabled())
+ log.debug("Mapping entry to near nodes [nodes=" + U.nodeIds(nearNodes) + ", entry=" +
+ entry + ']');
+
+ for (ClusterNode n : nearNodes) {
+ if (locNearMap == null)
+ locNearMap = new HashMap<>();
+
+ List<GridDhtCacheEntry> entries = locNearMap.get(n);
+
+ if (entries == null)
+ locNearMap.put(n, entries = new LinkedList<>());
+
+ entries.add(entry);
+ }
+ }
+
+ break;
+ }
+ catch (GridCacheEntryRemovedException ignored) {
+ // Retry.
+ txEntry.cached(txEntry.context().dht().entryExx(key.key(), topologyVersion()));
+ }
+ }
+ }
+
+ if (locNearMap != null)
+ addNearNodeEntryMapping(locNearMap);
+ }
+
+ /** {@inheritDoc} */
@SuppressWarnings({"CatchGenericClass", "ThrowableInstanceNeverThrown"})
@Override public boolean finish(boolean commit) throws IgniteCheckedException {
if (log.isDebugEnabled())
@@ -820,32 +885,6 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
*/
protected abstract void clearPrepareFuture(GridDhtTxPrepareFuture fut);
- /**
- * @return {@code True} if transaction is finished on prepare step.
- */
- protected final boolean commitOnPrepare() {
- return onePhaseCommit() && !near();
- }
-
- /**
- * @param prepFut Prepare future.
- * @return If transaction if finished on prepare step returns future which is completed after transaction finish.
- */
- protected final IgniteInternalFuture<GridNearTxPrepareResponse> chainOnePhasePrepare(
- final GridDhtTxPrepareFuture prepFut) {
- if (commitOnPrepare()) {
- return finishFuture().chain(new CX1<IgniteInternalFuture<IgniteInternalTx>, GridNearTxPrepareResponse>() {
- @Override public GridNearTxPrepareResponse applyx(IgniteInternalFuture<IgniteInternalTx> finishFut)
- throws IgniteCheckedException
- {
- return prepFut.get();
- }
- });
- }
-
- return prepFut;
- }
-
/** {@inheritDoc} */
@Override public void rollback() throws IgniteCheckedException {
try {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxMapping.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxMapping.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxMapping.java
index ba2c35f..d207d76 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxMapping.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxMapping.java
@@ -28,7 +28,7 @@ import java.util.*;
/**
* DHT transaction mapping.
*/
-public class GridDhtTxMapping {
+public class GridDhtTxMapping<K, V> {
/** Transaction nodes mapping (primary node -> related backup nodes). */
private final Map<UUID, Collection<UUID>> txNodes = new GridLeanMap<>();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 3056ae5..3a1a80a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -50,32 +50,19 @@ import static org.apache.ignite.transactions.TransactionState.*;
*
*/
@SuppressWarnings("unchecked")
-public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInternalTx, GridNearTxPrepareResponse>
- implements GridCacheMvccFuture<GridNearTxPrepareResponse> {
+public final class GridDhtTxPrepareFuture<K, V> extends GridCompoundIdentityFuture<IgniteInternalTx>
+ implements GridCacheMvccFuture<IgniteInternalTx> {
/** */
private static final long serialVersionUID = 0L;
/** Logger reference. */
private static final AtomicReference<IgniteLogger> logRef = new AtomicReference<>();
- /** */
- private static final IgniteReducer<IgniteInternalTx, GridNearTxPrepareResponse> REDUCER =
- new IgniteReducer<IgniteInternalTx, GridNearTxPrepareResponse>() {
- @Override public boolean collect(IgniteInternalTx e) {
- return true;
- }
-
- @Override public GridNearTxPrepareResponse reduce() {
- // Nothing to aggregate.
- return null;
- }
- };
-
/** Logger. */
private static IgniteLogger log;
/** Context. */
- private GridCacheSharedContext<?, ?> cctx;
+ private GridCacheSharedContext<K, V> cctx;
/** Future ID. */
private IgniteUuid futId;
@@ -141,13 +128,15 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
/** */
private boolean invoke;
+ /** */
+ private IgniteInClosure<GridNearTxPrepareResponse> completeCb;
+
/**
* @param cctx Context.
* @param tx Transaction.
* @param nearMiniId Near mini future id.
* @param dhtVerMap DHT versions map.
* @param last {@code True} if this is last prepare operation for node.
- * @param retVal Return value flag.
* @param lastBackups IDs of backup nodes receiving last prepare request during this prepare.
*/
public GridDhtTxPrepareFuture(
@@ -157,9 +146,19 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
Map<IgniteTxKey, GridCacheVersion> dhtVerMap,
boolean last,
boolean retVal,
- Collection<UUID> lastBackups
+ Collection<UUID> lastBackups,
+ IgniteInClosure<GridNearTxPrepareResponse> completeCb
) {
- super(REDUCER);
+ super(cctx.kernalContext(), new IgniteReducer<IgniteInternalTx, IgniteInternalTx>() {
+ @Override public boolean collect(IgniteInternalTx e) {
+ return true;
+ }
+
+ @Override public IgniteInternalTx reduce() {
+ // Nothing to aggregate.
+ return tx;
+ }
+ });
this.cctx = cctx;
this.tx = tx;
@@ -179,6 +178,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
this.retVal = retVal;
+ this.completeCb = completeCb;
+
assert dhtMap != null;
assert nearMap != null;
}
@@ -381,7 +382,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
* @param t Error.
*/
public void onError(Throwable t) {
- onDone(null, t);
+ onDone(tx, t);
}
/**
@@ -414,7 +415,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (log.isDebugEnabled())
log.debug("Marking all local candidates as ready: " + this);
- Iterable<IgniteTxEntry> checkEntries = writes;
+ Iterable<IgniteTxEntry> checkEntries = tx.groupLock() ?
+ Collections.singletonList(tx.groupLockEntry()) : writes;
for (IgniteTxEntry txEntry : checkEntries) {
GridCacheContext cacheCtx = txEntry.context();
@@ -430,8 +432,10 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
txEntry.cached(entry);
}
- if (tx.optimistic() && txEntry.explicitVersion() == null)
- lockKeys.add(txEntry.txKey());
+ if (tx.optimistic() && txEntry.explicitVersion() == null) {
+ if (!tx.groupLock() || tx.groupLockKey().equals(entry.txKey()))
+ lockKeys.add(txEntry.txKey());
+ }
while (true) {
try {
@@ -475,7 +479,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
}
/** {@inheritDoc} */
- @Override public boolean onDone(GridNearTxPrepareResponse res0, Throwable err) {
+ @Override public boolean onDone(IgniteInternalTx tx0, Throwable err) {
assert err != null || (initialized() && !hasPending()) : "On done called for prepare future that has " +
"pending mini futures: " + this;
@@ -491,15 +495,16 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
// Must create prepare response before transaction is committed to grab correct return value.
final GridNearTxPrepareResponse res = createPrepareResponse();
- onComplete(res);
+ onComplete();
- if (tx.commitOnPrepare()) {
+ if (!tx.near()) {
if (tx.markFinalizing(IgniteInternalTx.FinalizationStatus.USER_FINISH)) {
IgniteInternalFuture<IgniteInternalTx> fut = this.err.get() == null ?
tx.commitAsync() : tx.rollbackAsync();
fut.listen(new CIX1<IgniteInternalFuture<IgniteInternalTx>>() {
- @Override public void applyx(IgniteInternalFuture<IgniteInternalTx> fut) {
+ @Override
+ public void applyx(IgniteInternalFuture<IgniteInternalTx> fut) {
try {
if (replied.compareAndSet(false, true))
sendPrepareResponse(res);
@@ -525,17 +530,15 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
}
else {
if (replied.compareAndSet(false, true)) {
- GridNearTxPrepareResponse res = createPrepareResponse();
-
try {
- sendPrepareResponse(res);
+ sendPrepareResponse(createPrepareResponse());
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to send prepare response for transaction: " + tx, e);
}
finally {
// Will call super.onDone().
- onComplete(res);
+ onComplete();
}
return true;
@@ -559,12 +562,16 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
}
/**
- * @param res Response.
* @throws IgniteCheckedException If failed to send response.
*/
private void sendPrepareResponse(GridNearTxPrepareResponse res) throws IgniteCheckedException {
if (!tx.nearNodeId().equals(cctx.localNodeId()))
cctx.io().send(tx.nearNodeId(), res, tx.ioPolicy());
+ else {
+ assert completeCb != null;
+
+ completeCb.apply(res);
+ }
}
/**
@@ -609,10 +616,10 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
for (IgniteTxEntry e : writes) {
IgniteTxEntry txEntry = tx.entry(e.txKey());
- assert txEntry != null : "Missing tx entry for key [tx=" + tx + ", key=" + e.txKey() + ']';
-
GridCacheContext cacheCtx = txEntry.context();
+ assert txEntry != null : "Missing tx entry for key [tx=" + tx + ", key=" + e.txKey() + ']';
+
while (true) {
try {
GridCacheEntryEx entry = txEntry.cached();
@@ -675,14 +682,13 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
/**
* Completeness callback.
*
- * @param res Response.
* @return {@code True} if {@code done} flag was changed as a result of this call.
*/
- private boolean onComplete(@Nullable GridNearTxPrepareResponse res) {
+ private boolean onComplete() {
if (last || tx.isSystemInvalidate())
tx.state(PREPARED);
- if (super.onDone(res, err.get())) {
+ if (super.onDone(tx, err.get())) {
// Don't forget to clean up.
cctx.mvcc().removeFuture(this);
@@ -696,7 +702,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
* Completes this future.
*/
public void complete() {
- onComplete(null);
+ onComplete();
}
/**
@@ -711,7 +717,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (tx.empty()) {
tx.setRollbackOnly();
- onDone((GridNearTxPrepareResponse)null);
+ onDone(tx);
}
this.reads = reads;
@@ -800,6 +806,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
tx,
dhtWrites,
nearWrites,
+ tx.groupLockKey(),
+ tx.partitionLock(),
txNodes,
tx.nearXidVersion(),
true,
@@ -813,11 +821,14 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
try {
GridDhtCacheEntry cached = (GridDhtCacheEntry)entry.cached();
- GridCacheContext<?, ?> cacheCtx = cached.context();
+ GridCacheContext<K, V> cacheCtx = cached.context();
if (entry.explicitVersion() == null) {
GridCacheMvccCandidate added = cached.candidate(version());
+ assert added != null || entry.groupLockEntry() :
+ "Null candidate for non-group-lock entry " +
+ "[added=" + added + ", entry=" + entry + ']';
assert added == null || added.dhtLocal() :
"Got non-dht-local candidate for prepare future " +
"[added=" + added + ", entry=" + entry + ']';
@@ -898,6 +909,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
tx,
null,
nearMapping.writes(),
+ tx.groupLockKey(),
+ tx.partitionLock(),
tx.transactionNodes(),
tx.nearXidVersion(),
true,
@@ -910,6 +923,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (entry.explicitVersion() == null) {
GridCacheMvccCandidate added = entry.cached().candidate(version());
+ assert added != null || entry.groupLockEntry() : "Null candidate for non-group-lock entry " +
+ "[added=" + added + ", entry=" + entry + ']';
assert added == null || added.dhtLocal() : "Got non-dht-local candidate for prepare future" +
"[added=" + added + ", entry=" + entry + ']';
@@ -962,7 +977,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
GridCacheContext cacheCtx = entry.context();
- GridDhtCacheAdapter<?, ?> dht = cacheCtx.isNear() ? cacheCtx.near().dht() : cacheCtx.dht();
+ GridDhtCacheAdapter<K, V> dht = cacheCtx.isNear() ? cacheCtx.near().dht() : cacheCtx.dht();
ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(entry);
@@ -1219,7 +1234,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
boolean rec = cctx.gridEvents().isRecordable(EVT_CACHE_REBALANCE_OBJECT_LOADED);
for (GridCacheEntryInfo info : res.preloadEntries()) {
- GridCacheContext<?, ?> cacheCtx = cctx.cacheContext(info.cacheId());
+ GridCacheContext<K, V> cacheCtx = cctx.cacheContext(info.cacheId());
while (true) {
GridCacheEntryEx entry = cacheCtx.cache().entryEx(info.key());
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
index 73f86fd..c033273 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
@@ -104,6 +104,8 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
* @param tx Transaction.
* @param dhtWrites DHT writes.
* @param nearWrites Near writes.
+ * @param grpLockKey Group lock key if preparing group-lock transaction.
+ * @param partLock {@code True} if group-lock transaction locks partition.
* @param txNodes Transaction nodes mapping.
* @param nearXidVer Near transaction ID.
* @param last {@code True} if this is last prepare request for node.
@@ -116,13 +118,15 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
GridDhtTxLocalAdapter tx,
Collection<IgniteTxEntry> dhtWrites,
Collection<IgniteTxEntry> nearWrites,
+ IgniteTxKey grpLockKey,
+ boolean partLock,
Map<UUID, Collection<UUID>> txNodes,
GridCacheVersion nearXidVer,
boolean last,
boolean onePhaseCommit,
UUID subjId,
int taskNameHash) {
- super(tx, null, dhtWrites, txNodes, onePhaseCommit);
+ super(tx, null, dhtWrites, grpLockKey, partLock, txNodes, onePhaseCommit);
assert futId != null;
assert miniId != null;
@@ -333,79 +337,79 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
}
switch (writer.state()) {
- case 23:
+ case 25:
if (!writer.writeIgniteUuid("futId", futId))
return false;
writer.incrementState();
- case 24:
+ case 26:
if (!writer.writeBitSet("invalidateNearEntries", invalidateNearEntries))
return false;
writer.incrementState();
- case 25:
+ case 27:
if (!writer.writeBoolean("last", last))
return false;
writer.incrementState();
- case 26:
+ case 28:
if (!writer.writeIgniteUuid("miniId", miniId))
return false;
writer.incrementState();
- case 27:
+ case 29:
if (!writer.writeUuid("nearNodeId", nearNodeId))
return false;
writer.incrementState();
- case 28:
+ case 30:
if (!writer.writeCollection("nearWrites", nearWrites, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
- case 29:
+ case 31:
if (!writer.writeMessage("nearXidVer", nearXidVer))
return false;
writer.incrementState();
- case 30:
+ case 32:
if (!writer.writeCollection("ownedKeys", ownedKeys, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
- case 31:
+ case 33:
if (!writer.writeCollection("ownedVals", ownedVals, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
- case 32:
+ case 34:
if (!writer.writeBitSet("preloadKeys", preloadKeys))
return false;
writer.incrementState();
- case 33:
+ case 35:
if (!writer.writeUuid("subjId", subjId))
return false;
writer.incrementState();
- case 34:
+ case 36:
if (!writer.writeInt("taskNameHash", taskNameHash))
return false;
writer.incrementState();
- case 35:
+ case 37:
if (!writer.writeMessage("topVer", topVer))
return false;
@@ -427,7 +431,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
return false;
switch (reader.state()) {
- case 23:
+ case 25:
futId = reader.readIgniteUuid("futId");
if (!reader.isLastRead())
@@ -435,7 +439,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 24:
+ case 26:
invalidateNearEntries = reader.readBitSet("invalidateNearEntries");
if (!reader.isLastRead())
@@ -443,7 +447,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 25:
+ case 27:
last = reader.readBoolean("last");
if (!reader.isLastRead())
@@ -451,7 +455,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 26:
+ case 28:
miniId = reader.readIgniteUuid("miniId");
if (!reader.isLastRead())
@@ -459,7 +463,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 27:
+ case 29:
nearNodeId = reader.readUuid("nearNodeId");
if (!reader.isLastRead())
@@ -467,7 +471,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 28:
+ case 30:
nearWrites = reader.readCollection("nearWrites", MessageCollectionItemType.MSG);
if (!reader.isLastRead())
@@ -475,7 +479,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 29:
+ case 31:
nearXidVer = reader.readMessage("nearXidVer");
if (!reader.isLastRead())
@@ -483,7 +487,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 30:
+ case 32:
ownedKeys = reader.readCollection("ownedKeys", MessageCollectionItemType.MSG);
if (!reader.isLastRead())
@@ -491,7 +495,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 31:
+ case 33:
ownedVals = reader.readCollection("ownedVals", MessageCollectionItemType.MSG);
if (!reader.isLastRead())
@@ -499,7 +503,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 32:
+ case 34:
preloadKeys = reader.readBitSet("preloadKeys");
if (!reader.isLastRead())
@@ -507,7 +511,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 33:
+ case 35:
subjId = reader.readUuid("subjId");
if (!reader.isLastRead())
@@ -515,7 +519,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 34:
+ case 36:
taskNameHash = reader.readInt("taskNameHash");
if (!reader.isLastRead())
@@ -523,7 +527,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 35:
+ case 37:
topVer = reader.readMessage("topVer");
if (!reader.isLastRead())
@@ -543,6 +547,6 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 36;
+ return 38;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
index 0a69910..30464a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
@@ -77,6 +77,7 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
* @param timeout Timeout.
* @param ctx Cache context.
* @param txSize Expected transaction size.
+ * @param grpLockKey Group lock key if this is a group-lock transaction.
* @param nearXidVer Near transaction ID.
* @param txNodes Transaction nodes mapping.
*/
@@ -96,13 +97,14 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
boolean invalidate,
long timeout,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
GridCacheVersion nearXidVer,
Map<UUID, Collection<UUID>> txNodes,
@Nullable UUID subjId,
int taskNameHash
) {
super(ctx, nodeId, rmtThreadId, xidVer, commitVer, sys, plc, concurrency, isolation, invalidate, timeout,
- txSize, subjId, taskNameHash);
+ txSize, grpLockKey, subjId, taskNameHash);
assert nearNodeId != null;
assert rmtFutId != null;
@@ -137,6 +139,7 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
* @param timeout Timeout.
* @param ctx Cache context.
* @param txSize Expected transaction size.
+ * @param grpLockKey Group lock key if transaction is group-lock.
*/
public GridDhtTxRemote(
GridCacheSharedContext ctx,
@@ -155,11 +158,12 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
boolean invalidate,
long timeout,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
@Nullable UUID subjId,
int taskNameHash
) {
super(ctx, nodeId, rmtThreadId, xidVer, commitVer, sys, plc, concurrency, isolation, invalidate, timeout,
- txSize, subjId, taskNameHash);
+ txSize, grpLockKey, subjId, taskNameHash);
assert nearNodeId != null;
assert rmtFutId != null;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridNoStorageCacheMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridNoStorageCacheMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridNoStorageCacheMap.java
index 098ec97..8da4da5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridNoStorageCacheMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridNoStorageCacheMap.java
@@ -86,9 +86,7 @@ public class GridNoStorageCacheMap extends GridCacheConcurrentMap {
boolean create)
{
if (create) {
- GridCacheMapEntry entry = ctx.useOffheapEntry() ?
- new GridDhtOffHeapCacheEntry(ctx, topVer, key, hash(key.hashCode()), val, null, 0) :
- new GridDhtCacheEntry(ctx, topVer, key, hash(key.hashCode()), val, null, 0);
+ GridCacheMapEntry entry = new GridDhtCacheEntry(ctx, topVer, key, hash(key.hashCode()), val, null, 0);
return new GridTriple<>(entry, null, null);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 19d88e0..905f7bf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -124,9 +124,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
GridCacheMapEntry next,
int hdrId)
{
- if (ctx.useOffheapEntry())
- return new GridDhtAtomicOffHeapCacheEntry(ctx, topVer, key, hash, val, next, hdrId);
-
return new GridDhtAtomicCacheEntry(ctx, topVer, key, hash, val, next, hdrId);
}
});
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicOffHeapCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicOffHeapCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicOffHeapCacheEntry.java
deleted file mode 100644
index 91a8e65..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicOffHeapCacheEntry.java
+++ /dev/null
@@ -1,63 +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.internal.processors.cache.distributed.dht.atomic;
-
-import org.apache.ignite.internal.processors.affinity.*;
-import org.apache.ignite.internal.processors.cache.*;
-
-/**
- * DHT atomic cache entry for off-heap tiered or off-heap values modes.
- */
-public class GridDhtAtomicOffHeapCacheEntry extends GridDhtAtomicCacheEntry {
- /** Off-heap value pointer. */
- private long valPtr;
-
- /**
- * @param ctx Cache context.
- * @param topVer Topology version at the time of creation (if negative, then latest topology is assumed).
- * @param key Cache key.
- * @param hash Key hash value.
- * @param val Entry value.
- * @param next Next entry in the linked list.
- * @param hdrId Header id.
- */
- public GridDhtAtomicOffHeapCacheEntry(GridCacheContext ctx,
- AffinityTopologyVersion topVer,
- KeyCacheObject key,
- int hash,
- CacheObject val,
- GridCacheMapEntry next,
- int hdrId) {
- super(ctx, topVer, key, hash, val, next, hdrId);
- }
-
- /** {@inheritDoc} */
- @Override protected boolean hasOffHeapPointer() {
- return valPtr != 0;
- }
-
- /** {@inheritDoc} */
- @Override protected long offHeapPointer() {
- return valPtr;
- }
-
- /** {@inheritDoc} */
- @Override protected void offHeapPointer(long valPtr) {
- this.valPtr = valPtr;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 05b3c7b..c92d9ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -86,9 +86,6 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
GridCacheMapEntry next,
int hdrId)
{
- if (ctx.useOffheapEntry())
- return new GridDhtColocatedOffHeapCacheEntry(ctx, topVer, key, hash, val, next, hdrId);
-
return new GridDhtColocatedCacheEntry(ctx, topVer, key, hash, val, next, hdrId);
}
});
@@ -129,7 +126,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
boolean allowDetached
) {
return allowDetached && !ctx.affinity().primary(ctx.localNode(), key, topVer) ?
- createEntry(key) : entryExx(key, topVer);
+ new GridDhtDetachedCacheEntry(ctx, key, key.hashCode(), null, null, 0) : entryExx(key, topVer);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index e6a4eaf..f10baa3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -754,6 +754,8 @@ public final class GridDhtColocatedLockFuture<K, V> extends GridCompoundIdentity
mappedKeys.size(),
inTx() ? tx.size() : mappedKeys.size(),
inTx() && tx.syncCommit(),
+ inTx() ? tx.groupLockKey() : null,
+ inTx() && tx.partitionLock(),
inTx() ? tx.subjectId() : null,
inTx() ? tx.taskNameHash() : 0,
read ? accessTtl : -1L,
@@ -1088,6 +1090,10 @@ public final class GridDhtColocatedLockFuture<K, V> extends GridCompoundIdentity
// If primary node left the grid before lock acquisition, fail the whole future.
throw newTopologyException(null, primary.id());
+ if (inTx() && tx.groupLock() && !primary.isLocal())
+ throw new IgniteCheckedException("Failed to start group lock transaction (local node is not primary for " +
+ " key) [key=" + key + ", primaryNodeId=" + primary.id() + ']');
+
if (mapping == null || !primary.id().equals(mapping.node().id()))
mapping = new GridNearLockMapping(primary, key);
else
@@ -1275,18 +1281,25 @@ public final class GridDhtColocatedLockFuture<K, V> extends GridCompoundIdentity
GridDhtDetachedCacheEntry entry = (GridDhtDetachedCacheEntry)txEntry.cached();
- if (res.dhtVersion(i) == null) {
- onDone(new IgniteCheckedException("Failed to receive DHT version from remote node " +
- "(will fail the lock): " + res));
+ try {
+ if (res.dhtVersion(i) == null) {
+ onDone(new IgniteCheckedException("Failed to receive DHT version from remote node " +
+ "(will fail the lock): " + res));
- return;
- }
+ return;
+ }
- // Set value to detached entry.
- entry.resetFromPrimary(newVal, dhtVer);
+ // Set value to detached entry.
+ entry.resetFromPrimary(newVal, dhtVer);
- if (log.isDebugEnabled())
- log.debug("Processed response for entry [res=" + res + ", entry=" + entry + ']');
+ if (log.isDebugEnabled())
+ log.debug("Processed response for entry [res=" + res + ", entry=" + entry + ']');
+ }
+ catch (IgniteCheckedException e) {
+ onDone(e);
+
+ return;
+ }
}
else
cctx.mvcc().markExplicitOwner(k, threadId);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedOffHeapCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedOffHeapCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedOffHeapCacheEntry.java
deleted file mode 100644
index ed842ad..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedOffHeapCacheEntry.java
+++ /dev/null
@@ -1,63 +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.internal.processors.cache.distributed.dht.colocated;
-
-import org.apache.ignite.internal.processors.affinity.*;
-import org.apache.ignite.internal.processors.cache.*;
-
-/**
- * Cache entry for colocated cache for off-heap tiered or off-heap values modes.
- */
-public class GridDhtColocatedOffHeapCacheEntry extends GridDhtColocatedCacheEntry {
- /** Off-heap value pointer. */
- private long valPtr;
-
- /**
- * @param ctx Cache context.
- * @param topVer Topology version at the time of creation (if negative, then latest topology is assumed).
- * @param key Cache key.
- * @param hash Key hash value.
- * @param val Entry value.
- * @param next Next entry in the linked list.
- * @param hdrId Header id.
- */
- public GridDhtColocatedOffHeapCacheEntry(GridCacheContext ctx,
- AffinityTopologyVersion topVer,
- KeyCacheObject key,
- int hash,
- CacheObject val,
- GridCacheMapEntry next,
- int hdrId) {
- super(ctx, topVer, key, hash, val, next, hdrId);
- }
-
- /** {@inheritDoc} */
- @Override protected boolean hasOffHeapPointer() {
- return valPtr != 0;
- }
-
- /** {@inheritDoc} */
- @Override protected long offHeapPointer() {
- return valPtr;
- }
-
- /** {@inheritDoc} */
- @Override protected void offHeapPointer(long valPtr) {
- this.valPtr = valPtr;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtDetachedCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtDetachedCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtDetachedCacheEntry.java
index 2c84bd4..5c4dd13 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtDetachedCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtDetachedCacheEntry.java
@@ -46,8 +46,10 @@ public class GridDhtDetachedCacheEntry extends GridDistributedCacheEntry {
*
* @param val Value.
* @param ver Version.
+ * @throws IgniteCheckedException If value unmarshalling failed.
*/
- public void resetFromPrimary(CacheObject val, GridCacheVersion ver) {
+ public void resetFromPrimary(CacheObject val, GridCacheVersion ver)
+ throws IgniteCheckedException {
value(val);
this.ver = ver;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index 4b8db00..45d332c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -1252,7 +1252,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
cctx.kernalContext().timeout().removeTimeoutObject(old);
GridTimeoutObject timeoutObj = new GridTimeoutObjectAdapter(
- cctx.gridConfig().getNetworkTimeout() * Math.max(1, cctx.gridConfig().getCacheConfiguration().length)) {
+ cctx.gridConfig().getNetworkTimeout() * cctx.gridConfig().getCacheConfiguration().length) {
@Override public void onTimeout() {
if (isDone())
return;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
index 8258b14..145e980 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -76,9 +76,6 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
) {
// Can't hold any locks here - this method is invoked when
// holding write-lock on the whole cache map.
- if (ctx.useOffheapEntry())
- return new GridNearOffHeapCacheEntry(ctx, key, hash, val, next, hdrId);
-
return new GridNearCacheEntry(ctx, key, hash, val, next, hdrId);
}
});
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
index 797fd32..c7fa4ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
@@ -204,13 +204,15 @@ public class GridNearCacheEntry extends GridDistributedCacheEntry {
* @param topVer Topology version.
* @return {@code True} if reset was done.
* @throws GridCacheEntryRemovedException If obsolete.
+ * @throws IgniteCheckedException If failed.
*/
+ @SuppressWarnings( {"RedundantTypeArguments"})
public boolean resetFromPrimary(CacheObject val,
GridCacheVersion ver,
GridCacheVersion dhtVer,
UUID primaryNodeId,
AffinityTopologyVersion topVer)
- throws GridCacheEntryRemovedException
+ throws GridCacheEntryRemovedException, IgniteCheckedException
{
assert dhtVer != null;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
index 0ffb4e5..a427b65 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
@@ -890,6 +890,8 @@ public final class GridNearLockFuture<K, V> extends GridCompoundIdentityFuture<B
mappedKeys.size(),
inTx() ? tx.size() : mappedKeys.size(),
inTx() && tx.syncCommit(),
+ inTx() ? tx.groupLockKey() : null,
+ inTx() && tx.partitionLock(),
inTx() ? tx.subjectId() : null,
inTx() ? tx.taskNameHash() : 0,
read ? accessTtl : -1L,
@@ -1186,6 +1188,10 @@ public final class GridNearLockFuture<K, V> extends GridCompoundIdentityFuture<B
// If primary node left the grid before lock acquisition, fail the whole future.
throw newTopologyException(null, primary.id());
+ if (inTx() && tx.groupLock() && !primary.isLocal())
+ throw new IgniteCheckedException("Failed to start group lock transaction (local node is not primary for " +
+ " key) [key=" + key + ", primaryNodeId=" + primary.id() + ']');
+
if (mapping == null || !primary.id().equals(mapping.node().id()))
mapping = new GridNearLockMapping(primary, key);
else
@@ -1444,6 +1450,11 @@ public final class GridNearLockFuture<K, V> extends GridCompoundIdentityFuture<B
// Replace old entry with new one.
entries.set(i, (GridDistributedCacheEntry)cctx.cache().entryEx(entry.key()));
}
+ catch (IgniteCheckedException e) {
+ onDone(e);
+
+ return;
+ }
}
i++;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
index e71dd65..1ba4bfe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
@@ -21,6 +21,7 @@ import org.apache.ignite.*;
import org.apache.ignite.internal.processors.affinity.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.processors.cache.distributed.*;
+import org.apache.ignite.internal.processors.cache.transactions.*;
import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.util.tostring.*;
import org.apache.ignite.internal.util.typedef.internal.*;
@@ -104,6 +105,8 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
* @param keyCnt Number of keys.
* @param txSize Expected transaction size.
* @param syncCommit Synchronous commit flag.
+ * @param grpLockKey Group lock key if this is a group-lock transaction.
+ * @param partLock If partition is locked.
* @param subjId Subject ID.
* @param taskNameHash Task name hash code.
* @param accessTtl TTL for read operation.
@@ -127,6 +130,8 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
int keyCnt,
int txSize,
boolean syncCommit,
+ @Nullable IgniteTxKey grpLockKey,
+ boolean partLock,
@Nullable UUID subjId,
int taskNameHash,
long accessTtl,
@@ -146,6 +151,8 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
timeout,
keyCnt,
txSize,
+ grpLockKey,
+ partLock,
skipStore);
assert topVer.compareTo(AffinityTopologyVersion.ZERO) > 0;
@@ -349,79 +356,79 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
}
switch (writer.state()) {
- case 21:
+ case 23:
if (!writer.writeLong("accessTtl", accessTtl))
return false;
writer.incrementState();
- case 22:
+ case 24:
if (!writer.writeObjectArray("dhtVers", dhtVers, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
- case 23:
+ case 25:
if (!writer.writeObjectArray("filter", filter, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
- case 24:
+ case 26:
if (!writer.writeBoolean("hasTransforms", hasTransforms))
return false;
writer.incrementState();
- case 25:
+ case 27:
if (!writer.writeBoolean("implicitSingleTx", implicitSingleTx))
return false;
writer.incrementState();
- case 26:
+ case 28:
if (!writer.writeBoolean("implicitTx", implicitTx))
return false;
writer.incrementState();
- case 27:
+ case 29:
if (!writer.writeIgniteUuid("miniId", miniId))
return false;
writer.incrementState();
- case 28:
+ case 30:
if (!writer.writeBoolean("onePhaseCommit", onePhaseCommit))
return false;
writer.incrementState();
- case 29:
+ case 31:
if (!writer.writeBoolean("retVal", retVal))
return false;
writer.incrementState();
- case 30:
+ case 32:
if (!writer.writeUuid("subjId", subjId))
return false;
writer.incrementState();
- case 31:
+ case 33:
if (!writer.writeBoolean("syncCommit", syncCommit))
return false;
writer.incrementState();
- case 32:
+ case 34:
if (!writer.writeInt("taskNameHash", taskNameHash))
return false;
writer.incrementState();
- case 33:
+ case 35:
if (!writer.writeMessage("topVer", topVer))
return false;
@@ -443,7 +450,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
return false;
switch (reader.state()) {
- case 21:
+ case 23:
accessTtl = reader.readLong("accessTtl");
if (!reader.isLastRead())
@@ -451,7 +458,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 22:
+ case 24:
dhtVers = reader.readObjectArray("dhtVers", MessageCollectionItemType.MSG, GridCacheVersion.class);
if (!reader.isLastRead())
@@ -459,7 +466,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 23:
+ case 25:
filter = reader.readObjectArray("filter", MessageCollectionItemType.MSG, CacheEntryPredicate.class);
if (!reader.isLastRead())
@@ -467,7 +474,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 24:
+ case 26:
hasTransforms = reader.readBoolean("hasTransforms");
if (!reader.isLastRead())
@@ -475,7 +482,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 25:
+ case 27:
implicitSingleTx = reader.readBoolean("implicitSingleTx");
if (!reader.isLastRead())
@@ -483,7 +490,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 26:
+ case 28:
implicitTx = reader.readBoolean("implicitTx");
if (!reader.isLastRead())
@@ -491,7 +498,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 27:
+ case 29:
miniId = reader.readIgniteUuid("miniId");
if (!reader.isLastRead())
@@ -499,7 +506,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 28:
+ case 30:
onePhaseCommit = reader.readBoolean("onePhaseCommit");
if (!reader.isLastRead())
@@ -507,7 +514,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 29:
+ case 31:
retVal = reader.readBoolean("retVal");
if (!reader.isLastRead())
@@ -515,7 +522,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 30:
+ case 32:
subjId = reader.readUuid("subjId");
if (!reader.isLastRead())
@@ -523,7 +530,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 31:
+ case 33:
syncCommit = reader.readBoolean("syncCommit");
if (!reader.isLastRead())
@@ -531,7 +538,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 32:
+ case 34:
taskNameHash = reader.readInt("taskNameHash");
if (!reader.isLastRead())
@@ -539,7 +546,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 33:
+ case 35:
topVer = reader.readMessage("topVer");
if (!reader.isLastRead())
@@ -559,7 +566,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 34;
+ return 36;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOffHeapCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOffHeapCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOffHeapCacheEntry.java
deleted file mode 100644
index 25eb869..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOffHeapCacheEntry.java
+++ /dev/null
@@ -1,60 +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.internal.processors.cache.distributed.near;
-
-import org.apache.ignite.internal.processors.cache.*;
-
-/**
- * Near cache entry for off-heap tiered or off-heap values modes.
- */
-public class GridNearOffHeapCacheEntry extends GridNearCacheEntry {
- /** Off-heap value pointer. */
- private long valPtr;
-
- /**
- * @param ctx Cache context.
- * @param key Cache key.
- * @param hash Key hash value.
- * @param val Entry value.
- * @param next Next entry in the linked list.
- * @param hdrId Header id.
- */
- public GridNearOffHeapCacheEntry(GridCacheContext ctx,
- KeyCacheObject key,
- int hash,
- CacheObject val,
- GridCacheMapEntry next,
- int hdrId) {
- super(ctx, key, hash, val, next, hdrId);
- }
-
- /** {@inheritDoc} */
- @Override protected boolean hasOffHeapPointer() {
- return valPtr != 0;
- }
-
- /** {@inheritDoc} */
- @Override protected long offHeapPointer() {
- return valPtr;
- }
-
- /** {@inheritDoc} */
- @Override protected void offHeapPointer(long valPtr) {
- this.valPtr = valPtr;
- }
-}
[7/8] incubator-ignite git commit: Revert "ignite-471: fixed NPE in
PortableMarshaller"
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
index c5ef22f..3a685cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cache.distributed;
import org.apache.ignite.*;
import org.apache.ignite.cluster.*;
-import org.apache.ignite.compute.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.cluster.*;
import org.apache.ignite.internal.processors.affinity.*;
@@ -31,17 +30,17 @@ import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.processors.datastreamer.*;
import org.apache.ignite.internal.processors.task.*;
import org.apache.ignite.internal.util.future.*;
-import org.apache.ignite.internal.util.lang.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
import org.apache.ignite.transactions.*;
import org.jetbrains.annotations.*;
import java.io.*;
import java.util.*;
+import java.util.concurrent.*;
-import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.*;
-import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.*;
+import static org.apache.ignite.internal.GridClosureCallMode.*;
/**
* Distributed cache implementation.
@@ -143,28 +142,21 @@ public abstract class GridDistributedCacheAdapter<K, V> extends GridCacheAdapter
try {
AffinityTopologyVersion topVer;
- boolean retry;
-
- CacheOperationContext opCtx = ctx.operationContextPerCall();
-
- boolean skipStore = opCtx != null && opCtx.skipStore();
-
do {
- retry = false;
-
topVer = ctx.affinity().affinityTopologyVersion();
// Send job to all data nodes.
Collection<ClusterNode> nodes = ctx.grid().cluster().forDataNodes(name()).nodes();
if (!nodes.isEmpty()) {
- ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
+ CacheOperationContext opCtx = ctx.operationContextPerCall();
- retry = !ctx.kernalContext().task().execute(
- new RemoveAllTask(ctx.name(), topVer, skipStore), null).get();
+ ctx.closures().callAsyncNoFailover(BROADCAST,
+ new GlobalRemoveAllCallable<>(name(), topVer, opCtx != null && opCtx.skipStore()), nodes,
+ true).get();
}
}
- while (ctx.affinity().affinityTopologyVersion().compareTo(topVer) != 0 || retry);
+ while (ctx.affinity().affinityTopologyVersion().compareTo(topVer) > 0);
}
catch (ClusterGroupEmptyCheckedException ignore) {
if (log.isDebugEnabled())
@@ -178,11 +170,7 @@ public abstract class GridDistributedCacheAdapter<K, V> extends GridCacheAdapter
AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();
- CacheOperationContext opCtx = ctx.operationContextPerCall();
-
- boolean skipStore = opCtx != null && opCtx.skipStore();
-
- removeAllAsync(opFut, topVer, skipStore);
+ removeAllAsync(opFut, topVer);
return opFut;
}
@@ -190,29 +178,27 @@ public abstract class GridDistributedCacheAdapter<K, V> extends GridCacheAdapter
/**
* @param opFut Future.
* @param topVer Topology version.
- * @param skipStore Skip store flag.
*/
- private void removeAllAsync(final GridFutureAdapter<Void> opFut, final AffinityTopologyVersion topVer,
- final boolean skipStore) {
+ private void removeAllAsync(final GridFutureAdapter<Void> opFut, final AffinityTopologyVersion topVer) {
Collection<ClusterNode> nodes = ctx.grid().cluster().forDataNodes(name()).nodes();
if (!nodes.isEmpty()) {
- ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
+ CacheOperationContext opCtx = ctx.operationContextPerCall();
- IgniteInternalFuture<Boolean> rmvAll = ctx.kernalContext().task().execute(
- new RemoveAllTask(ctx.name(), topVer, skipStore), null);
+ IgniteInternalFuture<?> rmvFut = ctx.closures().callAsyncNoFailover(BROADCAST,
+ new GlobalRemoveAllCallable<>(name(), topVer, opCtx != null && opCtx.skipStore()), nodes, true);
- rmvAll.listen(new IgniteInClosure<IgniteInternalFuture<Boolean>>() {
- @Override public void apply(IgniteInternalFuture<Boolean> fut) {
+ rmvFut.listen(new IgniteInClosure<IgniteInternalFuture<?>>() {
+ @Override public void apply(IgniteInternalFuture<?> fut) {
try {
- boolean retry = !fut.get();
+ fut.get();
AffinityTopologyVersion topVer0 = ctx.affinity().affinityTopologyVersion();
- if (topVer0.equals(topVer) && !retry)
+ if (topVer0.equals(topVer))
opFut.onDone();
else
- removeAllAsync(opFut, topVer0, skipStore);
+ removeAllAsync(opFut, topVer0);
}
catch (ClusterGroupEmptyCheckedException ignore) {
if (log.isDebugEnabled())
@@ -241,150 +227,97 @@ public abstract class GridDistributedCacheAdapter<K, V> extends GridCacheAdapter
}
/**
- * Remove task.
+ * Internal callable which performs remove all primary key mappings
+ * operation on a cache with the given name.
*/
@GridInternal
- private static class RemoveAllTask extends ComputeTaskAdapter<Object, Boolean> {
+ private static class GlobalRemoveAllCallable<K,V> implements Callable<Object>, Externalizable {
/** */
private static final long serialVersionUID = 0L;
/** Cache name. */
- private final String cacheName;
+ private String cacheName;
- /** Affinity topology version. */
- private final AffinityTopologyVersion topVer;
+ /** Topology version. */
+ private AffinityTopologyVersion topVer;
/** Skip store flag. */
- private final boolean skipStore;
+ private boolean skipStore;
+
+ /** Injected grid instance. */
+ @IgniteInstanceResource
+ private Ignite ignite;
/**
- * @param cacheName Cache name.
- * @param topVer Affinity topology version.
- * @param skipStore Skip store flag.
+ * Empty constructor for serialization.
*/
- public RemoveAllTask(String cacheName, AffinityTopologyVersion topVer, boolean skipStore) {
- this.cacheName = cacheName;
- this.topVer = topVer;
- this.skipStore = skipStore;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
- @Nullable Object arg) throws IgniteException {
- Map<ComputeJob, ClusterNode> jobs = new HashMap();
-
- for (ClusterNode node : subgrid)
- jobs.put(new GlobalRemoveAllJob(cacheName, topVer, skipStore), node);
-
- return jobs;
- }
-
- /** {@inheritDoc} */
- @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) {
- IgniteException e = res.getException();
-
- if (e != null) {
- if (e instanceof ClusterTopologyException)
- return ComputeJobResultPolicy.WAIT;
-
- throw new IgniteException("Remote job threw exception.", e);
- }
-
- return ComputeJobResultPolicy.WAIT;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Boolean reduce(List<ComputeJobResult> results) throws IgniteException {
- for (ComputeJobResult locRes : results) {
- if (locRes != null && (locRes.getException() != null || !locRes.<Boolean>getData()))
- return false;
- }
-
- return true;
+ public GlobalRemoveAllCallable() {
+ // No-op.
}
- }
- /**
- * Internal job which performs remove all primary key mappings
- * operation on a cache with the given name.
- */
- @GridInternal
- private static class GlobalRemoveAllJob<K,V> extends TopologyVersionAwareJob {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Skip store flag. */
- private final boolean skipStore;
/**
* @param cacheName Cache name.
* @param topVer Topology version.
* @param skipStore Skip store flag.
*/
- private GlobalRemoveAllJob(String cacheName, @NotNull AffinityTopologyVersion topVer, boolean skipStore) {
- super(cacheName, topVer);
-
+ private GlobalRemoveAllCallable(String cacheName, @NotNull AffinityTopologyVersion topVer, boolean skipStore) {
+ this.cacheName = cacheName;
+ this.topVer = topVer;
this.skipStore = skipStore;
}
- /** {@inheritDoc} */
- @Nullable @Override public Object localExecute(@Nullable IgniteInternalCache cache0) {
- GridCacheAdapter cache = ((IgniteKernal) ignite).context().cache().internalCache(cacheName);
+ /**
+ * {@inheritDoc}
+ */
+ @Override public Object call() throws Exception {
+ GridCacheAdapter<K, V> cacheAdapter = ((IgniteKernal)ignite).context().cache().internalCache(cacheName);
- if (cache == null)
- return true;
+ final GridCacheContext<K, V> ctx = cacheAdapter.context();
- final GridCacheContext<K, V> ctx = cache.context();
+ ctx.affinity().affinityReadyFuture(topVer).get();
ctx.gate().enter();
try {
if (!ctx.affinity().affinityTopologyVersion().equals(topVer))
- return false; // Ignore this remove request because remove request will be sent again.
+ return null; // Ignore this remove request because remove request will be sent again.
GridDhtCacheAdapter<K, V> dht;
GridNearCacheAdapter<K, V> near = null;
- if (cache instanceof GridNearCacheAdapter) {
- near = ((GridNearCacheAdapter<K, V>) cache);
+ if (cacheAdapter instanceof GridNearCacheAdapter) {
+ near = ((GridNearCacheAdapter<K, V>)cacheAdapter);
dht = near.dht();
}
else
- dht = (GridDhtCacheAdapter<K, V>) cache;
+ dht = (GridDhtCacheAdapter<K, V>)cacheAdapter;
try (DataStreamerImpl<KeyCacheObject, Object> dataLdr =
- (DataStreamerImpl) ignite.dataStreamer(cacheName)) {
- ((DataStreamerImpl) dataLdr).maxRemapCount(0);
+ (DataStreamerImpl)ignite.dataStreamer(cacheName)) {
+ ((DataStreamerImpl)dataLdr).maxRemapCount(0);
dataLdr.skipStore(skipStore);
dataLdr.receiver(DataStreamerCacheUpdaters.<KeyCacheObject, Object>batched());
- for (int part : ctx.affinity().primaryPartitions(ctx.localNodeId(), topVer)) {
- GridDhtLocalPartition locPart = dht.topology().localPartition(part, topVer, false);
+ for (GridDhtLocalPartition locPart : dht.topology().currentLocalPartitions()) {
+ if (!locPart.isEmpty() && locPart.primary(topVer)) {
+ for (GridDhtCacheEntry o : locPart.entries()) {
+ if (!o.obsoleteOrDeleted())
+ dataLdr.removeDataInternal(o.key());
+ }
+ }
+ }
- if (locPart == null || (ctx.rebalanceEnabled() && locPart.state() != OWNING) || !locPart.reserve())
- return false;
+ Iterator<KeyCacheObject> it = dht.context().swap().offHeapKeyIterator(true, false, topVer);
- try {
- if (!locPart.isEmpty()) {
- for (GridDhtCacheEntry o : locPart.entries()) {
- if (!o.obsoleteOrDeleted())
- dataLdr.removeDataInternal(o.key());
- }
- }
+ while (it.hasNext())
+ dataLdr.removeDataInternal(it.next());
- GridCloseableIterator<Map.Entry<byte[], GridCacheSwapEntry>> iter =
- dht.context().swap().iterator(part);
+ it = dht.context().swap().swapKeyIterator(true, false, topVer);
- if (iter != null) {
- for (Map.Entry<byte[], GridCacheSwapEntry> e : iter)
- dataLdr.removeDataInternal(ctx.toCacheKeyObject(e.getKey()));
- }
- }
- finally {
- locPart.release();
- }
- }
+ while (it.hasNext())
+ dataLdr.removeDataInternal(it.next());
}
if (near != null) {
@@ -396,14 +329,25 @@ public abstract class GridDistributedCacheAdapter<K, V> extends GridCacheAdapter
}
}
}
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
- }
finally {
ctx.gate().leave();
}
- return true;
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeString(out, cacheName);
+ out.writeObject(topVer);
+ out.writeBoolean(skipStore);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ cacheName = U.readString(in);
+ topVer = (AffinityTopologyVersion)in.readObject();
+ skipStore = in.readBoolean();
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
index c5ac847..fd1040f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache.distributed;
import org.apache.ignite.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.processors.cache.transactions.*;
import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.util.tostring.*;
import org.apache.ignite.internal.util.typedef.internal.*;
@@ -82,6 +83,12 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
/** Key count. */
private int txSize;
+ /** Group lock key if this is a group-lock transaction. */
+ private IgniteTxKey grpLockKey;
+
+ /** Partition lock flag. Only if group-lock transaction. */
+ private boolean partLock;
+
/**
* Additional flags.
* GridCacheUtils.SKIP_STORE_FLAG_MASK - for skipStore flag value.
@@ -109,6 +116,9 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
* @param timeout Lock timeout.
* @param keyCnt Number of keys.
* @param txSize Expected transaction size.
+ * @param grpLockKey Group lock key if this is a group-lock transaction.
+ * @param partLock {@code True} if this is a group-lock transaction request and whole partition is
+ * locked.
* @param skipStore Skip store flag.
*/
public GridDistributedLockRequest(
@@ -125,6 +135,8 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
long timeout,
int keyCnt,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
+ boolean partLock,
boolean skipStore
) {
super(lockVer, keyCnt);
@@ -144,6 +156,8 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
this.isInvalidate = isInvalidate;
this.timeout = timeout;
this.txSize = txSize;
+ this.grpLockKey = grpLockKey;
+ this.partLock = partLock;
retVals = new boolean[keyCnt];
@@ -281,6 +295,27 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
}
/**
+ * @return {@code True} if lock request for group-lock transaction.
+ */
+ public boolean groupLock() {
+ return grpLockKey != null;
+ }
+
+ /**
+ * @return Group lock key.
+ */
+ @Nullable public IgniteTxKey groupLockKey() {
+ return grpLockKey;
+ }
+
+ /**
+ * @return {@code True} if partition is locked in group-lock transaction.
+ */
+ public boolean partitionLock() {
+ return partLock;
+ }
+
+ /**
* @return Max lock wait time.
*/
public long timeout() {
@@ -295,6 +330,9 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
GridCacheContext cctx = ctx.cacheContext(cacheId);
prepareMarshalCacheObjects(keys, cctx);
+
+ if (grpLockKey != null)
+ grpLockKey.prepareMarshal(cctx);
}
/** {@inheritDoc} */
@@ -304,6 +342,9 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
GridCacheContext cctx = ctx.cacheContext(cacheId);
finishUnmarshalCacheObjects(keys, cctx, ldr);
+
+ if (grpLockKey != null)
+ grpLockKey.finishUnmarshal(cctx, ldr);
}
/** {@inheritDoc} */
@@ -334,66 +375,78 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
writer.incrementState();
case 10:
- if (!writer.writeBoolean("isInTx", isInTx))
+ if (!writer.writeMessage("grpLockKey", grpLockKey))
return false;
writer.incrementState();
case 11:
- if (!writer.writeBoolean("isInvalidate", isInvalidate))
+ if (!writer.writeBoolean("isInTx", isInTx))
return false;
writer.incrementState();
case 12:
- if (!writer.writeBoolean("isRead", isRead))
+ if (!writer.writeBoolean("isInvalidate", isInvalidate))
return false;
writer.incrementState();
case 13:
- if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1))
+ if (!writer.writeBoolean("isRead", isRead))
return false;
writer.incrementState();
case 14:
- if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG))
+ if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1))
return false;
writer.incrementState();
case 15:
- if (!writer.writeMessage("nearXidVer", nearXidVer))
+ if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
case 16:
- if (!writer.writeUuid("nodeId", nodeId))
+ if (!writer.writeMessage("nearXidVer", nearXidVer))
return false;
writer.incrementState();
case 17:
- if (!writer.writeBooleanArray("retVals", retVals))
+ if (!writer.writeUuid("nodeId", nodeId))
return false;
writer.incrementState();
case 18:
- if (!writer.writeLong("threadId", threadId))
+ if (!writer.writeBoolean("partLock", partLock))
return false;
writer.incrementState();
case 19:
- if (!writer.writeLong("timeout", timeout))
+ if (!writer.writeBooleanArray("retVals", retVals))
return false;
writer.incrementState();
case 20:
+ if (!writer.writeLong("threadId", threadId))
+ return false;
+
+ writer.incrementState();
+
+ case 21:
+ if (!writer.writeLong("timeout", timeout))
+ return false;
+
+ writer.incrementState();
+
+ case 22:
if (!writer.writeInt("txSize", txSize))
return false;
@@ -432,7 +485,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
reader.incrementState();
case 10:
- isInTx = reader.readBoolean("isInTx");
+ grpLockKey = reader.readMessage("grpLockKey");
if (!reader.isLastRead())
return false;
@@ -440,7 +493,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
reader.incrementState();
case 11:
- isInvalidate = reader.readBoolean("isInvalidate");
+ isInTx = reader.readBoolean("isInTx");
if (!reader.isLastRead())
return false;
@@ -448,7 +501,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
reader.incrementState();
case 12:
- isRead = reader.readBoolean("isRead");
+ isInvalidate = reader.readBoolean("isInvalidate");
if (!reader.isLastRead())
return false;
@@ -456,6 +509,14 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
reader.incrementState();
case 13:
+ isRead = reader.readBoolean("isRead");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 14:
byte isolationOrd;
isolationOrd = reader.readByte("isolation");
@@ -467,7 +528,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
reader.incrementState();
- case 14:
+ case 15:
keys = reader.readCollection("keys", MessageCollectionItemType.MSG);
if (!reader.isLastRead())
@@ -475,7 +536,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
reader.incrementState();
- case 15:
+ case 16:
nearXidVer = reader.readMessage("nearXidVer");
if (!reader.isLastRead())
@@ -483,7 +544,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
reader.incrementState();
- case 16:
+ case 17:
nodeId = reader.readUuid("nodeId");
if (!reader.isLastRead())
@@ -491,7 +552,15 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
reader.incrementState();
- case 17:
+ case 18:
+ partLock = reader.readBoolean("partLock");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 19:
retVals = reader.readBooleanArray("retVals");
if (!reader.isLastRead())
@@ -499,7 +568,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
reader.incrementState();
- case 18:
+ case 20:
threadId = reader.readLong("threadId");
if (!reader.isLastRead())
@@ -507,7 +576,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
reader.incrementState();
- case 19:
+ case 21:
timeout = reader.readLong("timeout");
if (!reader.isLastRead())
@@ -515,7 +584,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
reader.incrementState();
- case 20:
+ case 22:
txSize = reader.readInt("txSize");
if (!reader.isLastRead())
@@ -535,7 +604,7 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 21;
+ return 23;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
index c524575..9672a75 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
@@ -18,8 +18,10 @@
package org.apache.ignite.internal.processors.cache.distributed;
import org.apache.ignite.*;
+import org.apache.ignite.internal.*;
import org.apache.ignite.internal.managers.communication.*;
import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.processors.cache.transactions.*;
import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.util.tostring.*;
import org.apache.ignite.lang.*;
@@ -64,6 +66,9 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
/** Expected txSize. */
private int txSize;
+ /** Group lock key. */
+ private IgniteTxKey grpLockKey;
+
/** System transaction flag. */
private boolean sys;
@@ -90,6 +95,7 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
* @param committedVers Committed versions.
* @param rolledbackVers Rolled back versions.
* @param txSize Expected transaction size.
+ * @param grpLockKey Group lock key if this is a group-lock transaction.
*/
public GridDistributedTxFinishRequest(
GridCacheVersion xidVer,
@@ -105,7 +111,8 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
GridCacheVersion baseVer,
Collection<GridCacheVersion> committedVers,
Collection<GridCacheVersion> rolledbackVers,
- int txSize
+ int txSize,
+ @Nullable IgniteTxKey grpLockKey
) {
super(xidVer, 0);
assert xidVer != null;
@@ -121,6 +128,7 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
this.syncRollback = syncRollback;
this.baseVer = baseVer;
this.txSize = txSize;
+ this.grpLockKey = grpLockKey;
completedVersions(committedVers, rolledbackVers);
}
@@ -211,15 +219,35 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
return commit ? syncCommit : syncRollback;
}
+ /**
+ * @return {@code True} if group lock transaction.
+ */
+ public boolean groupLock() {
+ return grpLockKey != null;
+ }
+
+ /**
+ * @return Group lock key.
+ */
+ @Nullable public IgniteTxKey groupLockKey() {
+ return grpLockKey;
+ }
+
/** {@inheritDoc}
* @param ctx*/
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);
+
+ if (grpLockKey != null)
+ grpLockKey.prepareMarshal(ctx.cacheContext(cacheId));
}
/** {@inheritDoc} */
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
+
+ if (grpLockKey != null)
+ grpLockKey.finishUnmarshal(ctx.cacheContext(cacheId), ldr);
}
/** {@inheritDoc} */
@@ -262,42 +290,48 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
writer.incrementState();
case 12:
- if (!writer.writeBoolean("invalidate", invalidate))
+ if (!writer.writeMessage("grpLockKey", grpLockKey))
return false;
writer.incrementState();
case 13:
- if (!writer.writeByte("plc", plc != null ? (byte)plc.ordinal() : -1))
+ if (!writer.writeBoolean("invalidate", invalidate))
return false;
writer.incrementState();
case 14:
- if (!writer.writeBoolean("syncCommit", syncCommit))
+ if (!writer.writeByte("plc", plc != null ? (byte)plc.ordinal() : -1))
return false;
writer.incrementState();
case 15:
- if (!writer.writeBoolean("syncRollback", syncRollback))
+ if (!writer.writeBoolean("syncCommit", syncCommit))
return false;
writer.incrementState();
case 16:
- if (!writer.writeBoolean("sys", sys))
+ if (!writer.writeBoolean("syncRollback", syncRollback))
return false;
writer.incrementState();
case 17:
- if (!writer.writeLong("threadId", threadId))
+ if (!writer.writeBoolean("sys", sys))
return false;
writer.incrementState();
case 18:
+ if (!writer.writeLong("threadId", threadId))
+ return false;
+
+ writer.incrementState();
+
+ case 19:
if (!writer.writeInt("txSize", txSize))
return false;
@@ -352,7 +386,7 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
reader.incrementState();
case 12:
- invalidate = reader.readBoolean("invalidate");
+ grpLockKey = reader.readMessage("grpLockKey");
if (!reader.isLastRead())
return false;
@@ -360,6 +394,14 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
reader.incrementState();
case 13:
+ invalidate = reader.readBoolean("invalidate");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 14:
byte plcOrd;
plcOrd = reader.readByte("plc");
@@ -371,7 +413,7 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
reader.incrementState();
- case 14:
+ case 15:
syncCommit = reader.readBoolean("syncCommit");
if (!reader.isLastRead())
@@ -379,7 +421,7 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
reader.incrementState();
- case 15:
+ case 16:
syncRollback = reader.readBoolean("syncRollback");
if (!reader.isLastRead())
@@ -387,7 +429,7 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
reader.incrementState();
- case 16:
+ case 17:
sys = reader.readBoolean("sys");
if (!reader.isLastRead())
@@ -395,7 +437,7 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
reader.incrementState();
- case 17:
+ case 18:
threadId = reader.readLong("threadId");
if (!reader.isLastRead())
@@ -403,7 +445,7 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
reader.incrementState();
- case 18:
+ case 19:
txSize = reader.readInt("txSize");
if (!reader.isLastRead())
@@ -423,7 +465,7 @@ public class GridDistributedTxFinishRequest extends GridDistributedBaseMessage {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 19;
+ return 20;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
index d11b879..aba9e86 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
@@ -88,6 +88,18 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
@GridDirectCollection(GridCacheVersion.class)
private Collection<GridCacheVersion> dhtVerVals;
+ /** Group lock key, if any. */
+ @GridToStringInclude
+ @GridDirectTransient
+ private IgniteTxKey grpLockKey;
+
+ /** Group lock key bytes. */
+ @GridToStringExclude
+ private ByteBuffer grpLockKeyBytes;
+
+ /** Partition lock flag. */
+ private boolean partLock;
+
/** Expected transaction size. */
private int txSize;
@@ -118,6 +130,8 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
* @param tx Cache transaction.
* @param reads Read entries.
* @param writes Write entries.
+ * @param grpLockKey Group lock key.
+ * @param partLock {@code True} if preparing group-lock transaction with partition lock.
* @param txNodes Transaction nodes mapping.
* @param onePhaseCommit One phase commit flag.
*/
@@ -125,6 +139,8 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
IgniteInternalTx tx,
@Nullable Collection<IgniteTxEntry> reads,
Collection<IgniteTxEntry> writes,
+ IgniteTxKey grpLockKey,
+ boolean partLock,
Map<UUID, Collection<UUID>> txNodes,
boolean onePhaseCommit
) {
@@ -142,6 +158,8 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
this.reads = reads;
this.writes = writes;
+ this.grpLockKey = grpLockKey;
+ this.partLock = partLock;
this.txNodes = txNodes;
this.onePhaseCommit = onePhaseCommit;
}
@@ -254,6 +272,20 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
}
/**
+ * @return Group lock key if preparing group-lock transaction.
+ */
+ @Nullable public IgniteTxKey groupLockKey() {
+ return grpLockKey;
+ }
+
+ /**
+ * @return {@code True} if preparing group-lock transaction with partition lock.
+ */
+ public boolean partitionLock() {
+ return partLock;
+ }
+
+ /**
* @return Expected transaction size.
*/
public int txSize() {
@@ -278,6 +310,9 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
if (reads != null)
marshalTx(reads, ctx);
+ if (grpLockKey != null && grpLockKeyBytes == null)
+ grpLockKeyBytes = ctx.marshaller().marshal(grpLockKey);
+
if (dhtVers != null) {
for (IgniteTxKey key : dhtVers.keySet()) {
GridCacheContext cctx = ctx.cacheContext(key.cacheId());
@@ -303,6 +338,9 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
if (reads != null)
unmarshalTx(reads, false, ctx, ldr);
+ if (grpLockKeyBytes != null && grpLockKey == null)
+ grpLockKey = ctx.marshaller().unmarshal(grpLockKeyBytes, ldr);
+
if (dhtVerKeys != null && dhtVers == null) {
assert dhtVerVals != null;
assert dhtVerKeys.size() == dhtVerVals.size();
@@ -359,72 +397,84 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
writer.incrementState();
case 11:
- if (!writer.writeBoolean("invalidate", invalidate))
+ if (!writer.writeByteBuffer("grpLockKeyBytes", grpLockKeyBytes))
return false;
writer.incrementState();
case 12:
- if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1))
+ if (!writer.writeBoolean("invalidate", invalidate))
return false;
writer.incrementState();
case 13:
- if (!writer.writeBoolean("onePhaseCommit", onePhaseCommit))
+ if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1))
return false;
writer.incrementState();
case 14:
- if (!writer.writeByte("plc", plc != null ? (byte)plc.ordinal() : -1))
+ if (!writer.writeBoolean("onePhaseCommit", onePhaseCommit))
return false;
writer.incrementState();
case 15:
- if (!writer.writeCollection("reads", reads, MessageCollectionItemType.MSG))
+ if (!writer.writeBoolean("partLock", partLock))
return false;
writer.incrementState();
case 16:
- if (!writer.writeBoolean("sys", sys))
+ if (!writer.writeByte("plc", plc != null ? (byte)plc.ordinal() : -1))
return false;
writer.incrementState();
case 17:
- if (!writer.writeLong("threadId", threadId))
+ if (!writer.writeCollection("reads", reads, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
case 18:
- if (!writer.writeLong("timeout", timeout))
+ if (!writer.writeBoolean("sys", sys))
return false;
writer.incrementState();
case 19:
- if (!writer.writeByteBuffer("txNodesBytes", txNodesBytes))
+ if (!writer.writeLong("threadId", threadId))
return false;
writer.incrementState();
case 20:
- if (!writer.writeInt("txSize", txSize))
+ if (!writer.writeLong("timeout", timeout))
return false;
writer.incrementState();
case 21:
- if (!writer.writeMessage("writeVer", writeVer))
+ if (!writer.writeByteBuffer("txNodesBytes", txNodesBytes))
return false;
writer.incrementState();
case 22:
+ if (!writer.writeInt("txSize", txSize))
+ return false;
+
+ writer.incrementState();
+
+ case 23:
+ if (!writer.writeMessage("writeVer", writeVer))
+ return false;
+
+ writer.incrementState();
+
+ case 24:
if (!writer.writeCollection("writes", writes, MessageCollectionItemType.MSG))
return false;
@@ -475,7 +525,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
case 11:
- invalidate = reader.readBoolean("invalidate");
+ grpLockKeyBytes = reader.readByteBuffer("grpLockKeyBytes");
if (!reader.isLastRead())
return false;
@@ -483,6 +533,14 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
case 12:
+ invalidate = reader.readBoolean("invalidate");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 13:
byte isolationOrd;
isolationOrd = reader.readByte("isolation");
@@ -494,7 +552,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
- case 13:
+ case 14:
onePhaseCommit = reader.readBoolean("onePhaseCommit");
if (!reader.isLastRead())
@@ -502,7 +560,15 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
- case 14:
+ case 15:
+ partLock = reader.readBoolean("partLock");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 16:
byte plcOrd;
plcOrd = reader.readByte("plc");
@@ -514,7 +580,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
- case 15:
+ case 17:
reads = reader.readCollection("reads", MessageCollectionItemType.MSG);
if (!reader.isLastRead())
@@ -522,7 +588,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
- case 16:
+ case 18:
sys = reader.readBoolean("sys");
if (!reader.isLastRead())
@@ -530,7 +596,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
- case 17:
+ case 19:
threadId = reader.readLong("threadId");
if (!reader.isLastRead())
@@ -538,7 +604,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
- case 18:
+ case 20:
timeout = reader.readLong("timeout");
if (!reader.isLastRead())
@@ -546,7 +612,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
- case 19:
+ case 21:
txNodesBytes = reader.readByteBuffer("txNodesBytes");
if (!reader.isLastRead())
@@ -554,7 +620,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
- case 20:
+ case 22:
txSize = reader.readInt("txSize");
if (!reader.isLastRead())
@@ -562,7 +628,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
- case 21:
+ case 23:
writeVer = reader.readMessage("writeVer");
if (!reader.isLastRead())
@@ -570,7 +636,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
reader.incrementState();
- case 22:
+ case 24:
writes = reader.readCollection("writes", MessageCollectionItemType.MSG);
if (!reader.isLastRead())
@@ -590,7 +656,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 23;
+ return 25;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
index 8594853..3215138 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
@@ -95,6 +95,7 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
* @param invalidate Invalidate flag.
* @param timeout Timeout.
* @param txSize Expected transaction size.
+ * @param grpLockKey Group lock key if this is a group-lock transaction.
* @param subjId Subject ID.
* @param taskNameHash Task name hash code.
*/
@@ -111,6 +112,7 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
boolean invalidate,
long timeout,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
@Nullable UUID subjId,
int taskNameHash
) {
@@ -126,6 +128,7 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
isolation,
timeout,
txSize,
+ grpLockKey,
subjId,
taskNameHash);
@@ -192,6 +195,16 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
// No-op.
}
+ /**
+ * Adds group lock key to remote transaction.
+ *
+ * @param key Key.
+ */
+ public void groupLockKey(IgniteTxKey key) {
+ if (grpLockKey == null)
+ grpLockKey = key;
+ }
+
/** {@inheritDoc} */
@Override public GridTuple<CacheObject> peek(GridCacheContext cacheCtx,
boolean failFast,
@@ -337,6 +350,7 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
entry.op(e.op());
entry.ttl(e.ttl());
entry.explicitVersion(e.explicitVersion());
+ entry.groupLockEntry(e.groupLockEntry());
// Conflict resolution stuff.
entry.conflictVersion(e.conflictVersion());
@@ -432,7 +446,7 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
GridCacheVersion ver = txEntry.explicitVersion() != null ? txEntry.explicitVersion() : xidVer;
// If locks haven't been acquired yet, keep waiting.
- if (!Entry.lockedBy(ver)) {
+ if (!txEntry.groupLockEntry() && !Entry.lockedBy(ver)) {
if (log.isDebugEnabled())
log.debug("Transaction does not own lock for entry (will wait) [entry=" + Entry +
", tx=" + this + ']');
@@ -593,6 +607,10 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
}
// No-op.
else {
+ assert !groupLock() || txEntry.groupLockEntry() || ownsLock(txEntry.cached()):
+ "Transaction does not own lock for group lock entry during commit [tx=" +
+ this + ", txEntry=" + txEntry + ']';
+
if (conflictCtx == null || !conflictCtx.isUseOld()) {
if (txEntry.ttl() != CU.TTL_NOT_CHANGED)
cached.updateTtl(null, txEntry.ttl());
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 23060e6..1c46fd0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -102,9 +102,6 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
GridCacheMapEntry next,
int hdrId)
{
- if (ctx.useOffheapEntry())
- return new GridDhtOffHeapCacheEntry(ctx, topVer, key, hash, val, next, hdrId);
-
return new GridDhtCacheEntry(ctx, topVer, key, hash, val, next, hdrId);
}
});
@@ -346,24 +343,17 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
public GridCacheEntryEx entryExx(KeyCacheObject key, AffinityTopologyVersion topVer, boolean allowDetached, boolean touch) {
try {
return allowDetached && !ctx.affinity().localNode(key, topVer) ?
- createEntry(key) : entryEx(key, touch);
+ new GridDhtDetachedCacheEntry(ctx, key, key.hashCode(), null, null, 0) :
+ entryEx(key, touch);
}
catch (GridDhtInvalidPartitionException e) {
if (!allowDetached)
throw e;
- return createEntry(key);
+ return new GridDhtDetachedCacheEntry(ctx, key, key.hashCode(), null, null, 0);
}
}
- /**
- * @param key Key for which entry should be returned.
- * @return Cache entry.
- */
- protected GridDistributedCacheEntry createEntry(KeyCacheObject key) {
- return new GridDhtDetachedCacheEntry(ctx, key, key.hashCode(), null, null, 0);
- }
-
/** {@inheritDoc} */
@Override public void localLoad(Collection<? extends K> keys, final ExpiryPolicy plc)
throws IgniteCheckedException {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
index c57eded..5b0275c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
@@ -833,6 +833,8 @@ public final class GridDhtLockFuture<K, V> extends GridCompoundIdentityFuture<Bo
cnt,
0,
inTx() ? tx.size() : cnt,
+ inTx() ? tx.groupLockKey() : null,
+ inTx() && tx.partitionLock(),
inTx() ? tx.subjectId() : null,
inTx() ? tx.taskNameHash() : 0,
read ? accessTtl : -1L,
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
index e08344f..b8e57a4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
@@ -22,6 +22,7 @@ import org.apache.ignite.internal.*;
import org.apache.ignite.internal.processors.affinity.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.processors.cache.distributed.*;
+import org.apache.ignite.internal.processors.cache.transactions.*;
import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.util.*;
import org.apache.ignite.internal.util.tostring.*;
@@ -100,6 +101,8 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
* @param dhtCnt DHT count.
* @param nearCnt Near count.
* @param txSize Expected transaction size.
+ * @param grpLockKey Group lock key.
+ * @param partLock {@code True} if partition lock.
* @param subjId Subject ID.
* @param taskNameHash Task name hash code.
* @param accessTtl TTL for read operation.
@@ -122,6 +125,8 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
int dhtCnt,
int nearCnt,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
+ boolean partLock,
@Nullable UUID subjId,
int taskNameHash,
long accessTtl,
@@ -140,6 +145,8 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
timeout,
dhtCnt == 0 ? nearCnt : dhtCnt,
txSize,
+ grpLockKey,
+ partLock,
skipStore);
this.topVer = topVer;
@@ -324,55 +331,55 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
}
switch (writer.state()) {
- case 21:
+ case 23:
if (!writer.writeLong("accessTtl", accessTtl))
return false;
writer.incrementState();
- case 22:
+ case 24:
if (!writer.writeBitSet("invalidateEntries", invalidateEntries))
return false;
writer.incrementState();
- case 23:
+ case 25:
if (!writer.writeIgniteUuid("miniId", miniId))
return false;
writer.incrementState();
- case 24:
+ case 26:
if (!writer.writeCollection("nearKeys", nearKeys, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
- case 25:
+ case 27:
if (!writer.writeByteBuffer("ownedBytes", ownedBytes))
return false;
writer.incrementState();
- case 26:
+ case 28:
if (!writer.writeBitSet("preloadKeys", preloadKeys))
return false;
writer.incrementState();
- case 27:
+ case 29:
if (!writer.writeUuid("subjId", subjId))
return false;
writer.incrementState();
- case 28:
+ case 30:
if (!writer.writeInt("taskNameHash", taskNameHash))
return false;
writer.incrementState();
- case 29:
+ case 31:
if (!writer.writeMessage("topVer", topVer))
return false;
@@ -394,7 +401,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
return false;
switch (reader.state()) {
- case 21:
+ case 23:
accessTtl = reader.readLong("accessTtl");
if (!reader.isLastRead())
@@ -402,7 +409,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 22:
+ case 24:
invalidateEntries = reader.readBitSet("invalidateEntries");
if (!reader.isLastRead())
@@ -410,7 +417,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 23:
+ case 25:
miniId = reader.readIgniteUuid("miniId");
if (!reader.isLastRead())
@@ -418,7 +425,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 24:
+ case 26:
nearKeys = reader.readCollection("nearKeys", MessageCollectionItemType.MSG);
if (!reader.isLastRead())
@@ -426,7 +433,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 25:
+ case 27:
ownedBytes = reader.readByteBuffer("ownedBytes");
if (!reader.isLastRead())
@@ -434,7 +441,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 26:
+ case 28:
preloadKeys = reader.readBitSet("preloadKeys");
if (!reader.isLastRead())
@@ -442,7 +449,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 27:
+ case 29:
subjId = reader.readUuid("subjId");
if (!reader.isLastRead())
@@ -450,7 +457,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 28:
+ case 30:
taskNameHash = reader.readInt("taskNameHash");
if (!reader.isLastRead())
@@ -458,7 +465,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 29:
+ case 31:
topVer = reader.readMessage("topVer");
if (!reader.isLastRead())
@@ -478,7 +485,7 @@ public class GridDhtLockRequest extends GridDistributedLockRequest {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 30;
+ return 32;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtOffHeapCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtOffHeapCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtOffHeapCacheEntry.java
deleted file mode 100644
index 1191d83..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtOffHeapCacheEntry.java
+++ /dev/null
@@ -1,63 +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.internal.processors.cache.distributed.dht;
-
-import org.apache.ignite.internal.processors.affinity.*;
-import org.apache.ignite.internal.processors.cache.*;
-
-/**
- * Replicated cache entry for off-heap tiered or off-heap values modes.
- */
-public class GridDhtOffHeapCacheEntry extends GridDhtCacheEntry {
- /** Off-heap value pointer. */
- private long valPtr;
-
- /**
- * @param ctx Cache context.
- * @param topVer Topology version at the time of creation (if negative, then latest topology is assumed).
- * @param key Cache key.
- * @param hash Key hash value.
- * @param val Entry value.
- * @param next Next entry in the linked list.
- * @param hdrId Header id.
- */
- public GridDhtOffHeapCacheEntry(GridCacheContext ctx,
- AffinityTopologyVersion topVer,
- KeyCacheObject key,
- int hash,
- CacheObject val,
- GridCacheMapEntry next,
- int hdrId) {
- super(ctx, topVer, key, hash, val, next, hdrId);
- }
-
- /** {@inheritDoc} */
- @Override protected boolean hasOffHeapPointer() {
- return valPtr != 0;
- }
-
- /** {@inheritDoc} */
- @Override protected long offHeapPointer() {
- return valPtr;
- }
-
- /** {@inheritDoc} */
- @Override protected void offHeapPointer(long valPtr) {
- this.valPtr = valPtr;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index 26eef50..87026f3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -174,7 +174,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
// Invalidate key in near cache, if any.
if (isNearEnabled(cacheCfg))
- obsoleteNearEntry(key);
+ obsoleteNearEntry(key, req.version());
break;
}
@@ -203,6 +203,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
req.isInvalidate(),
req.timeout(),
req.txSize(),
+ req.groupLockKey(),
req.subjectId(),
req.taskNameHash());
@@ -221,6 +222,9 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
null,
req.accessTtl(),
req.skipStore());
+
+ if (req.groupLock())
+ tx.groupLockKey(txKey);
}
entry = entryExx(key, req.topologyVersion());
@@ -287,7 +291,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
// Invalidate key in near cache, if any.
if (isNearEnabled(cacheCfg))
- obsoleteNearEntry(key);
+ obsoleteNearEntry(key, req.version());
if (tx != null) {
tx.clearEntry(txKey);
@@ -806,6 +810,8 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
req.isInvalidate(),
false,
req.txSize(),
+ req.groupLockKey(),
+ req.partitionLock(),
null,
req.subjectId(),
req.taskNameHash());
@@ -1475,11 +1481,12 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
/**
* @param key Key
+ * @param ver Version.
*/
- private void obsoleteNearEntry(KeyCacheObject key) {
+ private void obsoleteNearEntry(KeyCacheObject key, GridCacheVersion ver) {
GridCacheEntryEx nearEntry = near().peekEx(key);
if (nearEntry != null)
- nearEntry.markObsolete(ctx.versions().next());
+ nearEntry.markObsolete(ver);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
index 7fd79e5..7c35fc5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
@@ -309,6 +309,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
tx.rolledbackVersions(),
tx.pendingVersions(),
tx.size(),
+ tx.groupLockKey(),
tx.subjectId(),
tx.taskNameHash());
@@ -386,6 +387,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
tx.rolledbackVersions(),
tx.pendingVersions(),
tx.size(),
+ tx.groupLockKey(),
tx.subjectId(),
tx.taskNameHash());
@@ -437,6 +439,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
tx.rolledbackVersions(),
tx.pendingVersions(),
tx.size(),
+ tx.groupLockKey(),
tx.subjectId(),
tx.taskNameHash());
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
index 7b077c3..d20a7c3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
@@ -21,6 +21,7 @@ import org.apache.ignite.internal.*;
import org.apache.ignite.internal.processors.affinity.*;
import org.apache.ignite.internal.managers.communication.*;
import org.apache.ignite.internal.processors.cache.distributed.*;
+import org.apache.ignite.internal.processors.cache.transactions.*;
import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.util.tostring.*;
import org.apache.ignite.internal.util.typedef.internal.*;
@@ -96,6 +97,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
* @param rolledbackVers Rolled back versions.
* @param pendingVers Pending versions.
* @param txSize Expected transaction size.
+ * @param grpLockKey Group lock key.
* @param subjId Subject ID.
* @param taskNameHash Task name hash.
*/
@@ -120,11 +122,12 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
Collection<GridCacheVersion> rolledbackVers,
Collection<GridCacheVersion> pendingVers,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
@Nullable UUID subjId,
int taskNameHash
) {
super(xidVer, futId, commitVer, threadId, commit, invalidate, sys, plc, syncCommit, syncRollback, baseVer,
- committedVers, rolledbackVers, txSize);
+ committedVers, rolledbackVers, txSize, grpLockKey);
assert miniId != null;
assert nearNodeId != null;
@@ -238,55 +241,55 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
}
switch (writer.state()) {
- case 19:
+ case 20:
if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1))
return false;
writer.incrementState();
- case 20:
+ case 21:
if (!writer.writeIgniteUuid("miniId", miniId))
return false;
writer.incrementState();
- case 21:
+ case 22:
if (!writer.writeUuid("nearNodeId", nearNodeId))
return false;
writer.incrementState();
- case 22:
+ case 23:
if (!writer.writeCollection("pendingVers", pendingVers, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
- case 23:
+ case 24:
if (!writer.writeUuid("subjId", subjId))
return false;
writer.incrementState();
- case 24:
+ case 25:
if (!writer.writeBoolean("sysInvalidate", sysInvalidate))
return false;
writer.incrementState();
- case 25:
+ case 26:
if (!writer.writeInt("taskNameHash", taskNameHash))
return false;
writer.incrementState();
- case 26:
+ case 27:
if (!writer.writeMessage("topVer", topVer))
return false;
writer.incrementState();
- case 27:
+ case 28:
if (!writer.writeMessage("writeVer", writeVer))
return false;
@@ -308,7 +311,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
return false;
switch (reader.state()) {
- case 19:
+ case 20:
byte isolationOrd;
isolationOrd = reader.readByte("isolation");
@@ -320,7 +323,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 20:
+ case 21:
miniId = reader.readIgniteUuid("miniId");
if (!reader.isLastRead())
@@ -328,7 +331,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 21:
+ case 22:
nearNodeId = reader.readUuid("nearNodeId");
if (!reader.isLastRead())
@@ -336,7 +339,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 22:
+ case 23:
pendingVers = reader.readCollection("pendingVers", MessageCollectionItemType.MSG);
if (!reader.isLastRead())
@@ -344,7 +347,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 23:
+ case 24:
subjId = reader.readUuid("subjId");
if (!reader.isLastRead())
@@ -352,7 +355,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 24:
+ case 25:
sysInvalidate = reader.readBoolean("sysInvalidate");
if (!reader.isLastRead())
@@ -360,7 +363,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 25:
+ case 26:
taskNameHash = reader.readInt("taskNameHash");
if (!reader.isLastRead())
@@ -368,7 +371,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 26:
+ case 27:
topVer = reader.readMessage("topVer");
if (!reader.isLastRead())
@@ -376,7 +379,7 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
reader.incrementState();
- case 27:
+ case 28:
writeVer = reader.readMessage("writeVer");
if (!reader.isLastRead())
@@ -396,6 +399,6 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 28;
+ return 29;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
index 841cac8..07ced0d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
@@ -93,6 +93,8 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
* @param timeout Timeout.
* @param storeEnabled Store enabled flag.
* @param txSize Expected transaction size.
+ * @param grpLockKey Group lock key if this is a group-lock transaction.
+ * @param partLock {@code True} if this is a group-lock transaction and whole partition should be locked.
* @param txNodes Transaction nodes mapping.
*/
public GridDhtTxLocal(
@@ -113,6 +115,8 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
boolean invalidate,
boolean storeEnabled,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
+ boolean partLock,
Map<UUID, Collection<UUID>> txNodes,
UUID subjId,
int taskNameHash
@@ -131,6 +135,8 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
invalidate,
storeEnabled,
txSize,
+ grpLockKey,
+ partLock,
subjId,
taskNameHash);
@@ -278,7 +284,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
}
/** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> prepareAsync() {
+ @Override public IgniteInternalFuture<IgniteInternalTx> prepareAsync() {
if (optimistic()) {
assert isSystemInvalidate();
@@ -290,6 +296,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
nearMiniId,
null,
true,
+ null,
null);
}
@@ -298,13 +305,14 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
if (fut == null) {
// Future must be created before any exception can be thrown.
- if (!prepFut.compareAndSet(null, fut = new GridDhtTxPrepareFuture(
+ if (!prepFut.compareAndSet(null, fut = new GridDhtTxPrepareFuture<>(
cctx,
this,
nearMiniId,
Collections.<IgniteTxKey, GridCacheVersion>emptyMap(),
true,
needReturnValue(),
+ null,
null)))
return prepFut.get();
}
@@ -363,7 +371,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
* @param lastBackups IDs of backup nodes receiving last prepare request.
* @return Future that will be completed when locks are acquired.
*/
- public IgniteInternalFuture<GridNearTxPrepareResponse> prepareAsync(
+ public IgniteInternalFuture<IgniteInternalTx> prepareAsync(
@Nullable Iterable<IgniteTxEntry> reads,
@Nullable Iterable<IgniteTxEntry> writes,
Map<IgniteTxKey, GridCacheVersion> verMap,
@@ -371,7 +379,8 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
IgniteUuid nearMiniId,
Map<UUID, Collection<UUID>> txNodes,
boolean last,
- Collection<UUID> lastBackups
+ Collection<UUID> lastBackups,
+ IgniteInClosure<GridNearTxPrepareResponse> completeCb
) {
// In optimistic mode prepare still can be called explicitly from salvageTx.
GridDhtTxPrepareFuture fut = prepFut.get();
@@ -380,20 +389,21 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
init();
// Future must be created before any exception can be thrown.
- if (!prepFut.compareAndSet(null, fut = new GridDhtTxPrepareFuture(
+ if (!prepFut.compareAndSet(null, fut = new GridDhtTxPrepareFuture<>(
cctx,
this,
nearMiniId,
verMap,
last,
needReturnValue(),
- lastBackups))) {
+ lastBackups,
+ completeCb))) {
GridDhtTxPrepareFuture f = prepFut.get();
assert f.nearMiniId().equals(nearMiniId) : "Wrong near mini id on existing future " +
"[futMiniId=" + f.nearMiniId() + ", miniId=" + nearMiniId + ", fut=" + f + ']';
- return chainOnePhasePrepare(f);
+ return f;
}
}
else {
@@ -401,7 +411,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
"[futMiniId=" + fut.nearMiniId() + ", miniId=" + nearMiniId + ", fut=" + fut + ']';
// Prepare was called explicitly.
- return chainOnePhasePrepare(fut);
+ return fut;
}
if (state() != PREPARING) {
@@ -465,7 +475,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
}
}
- return chainOnePhasePrepare(fut);
+ return fut;
}
/** {@inheritDoc} */
@@ -507,8 +517,8 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
}
}
else
- prep.listen(new CI1<IgniteInternalFuture<?>>() {
- @Override public void apply(IgniteInternalFuture<?> f) {
+ prep.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
+ @Override public void apply(IgniteInternalFuture<IgniteInternalTx> f) {
try {
f.get(); // Check for errors of a parent future.
@@ -595,8 +605,8 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
else {
prepFut.complete();
- prepFut.listen(new CI1<IgniteInternalFuture<?>>() {
- @Override public void apply(IgniteInternalFuture<?> f) {
+ prepFut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
+ @Override public void apply(IgniteInternalFuture<IgniteInternalTx> f) {
try {
f.get(); // Check for errors of a parent future.
}
@@ -676,7 +686,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
- @Nullable @Override public IgniteInternalFuture<?> currentPrepareFuture() {
+ @Nullable @Override public IgniteInternalFuture<IgniteInternalTx> currentPrepareFuture() {
return prepFut.get();
}
[4/8] incubator-ignite git commit: Revert "ignite-471: fixed NPE in
PortableMarshaller"
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java
deleted file mode 100644
index 60b918c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java
+++ /dev/null
@@ -1,226 +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.internal.processors.cache.distributed.near;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.processors.cache.distributed.*;
-import org.apache.ignite.internal.processors.cache.distributed.dht.*;
-import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.*;
-import org.apache.ignite.internal.processors.cache.transactions.*;
-import org.apache.ignite.internal.processors.cache.version.*;
-import org.apache.ignite.internal.util.future.*;
-import org.apache.ignite.internal.util.tostring.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
-
-import javax.cache.expiry.*;
-import java.util.*;
-import java.util.concurrent.atomic.*;
-
-import static org.apache.ignite.internal.processors.cache.GridCacheOperation.*;
-
-/**
- * Common code for tx prepare in optimistic and pessimistic modes.
- */
-public abstract class GridNearTxPrepareFutureAdapter extends GridCompoundIdentityFuture<IgniteInternalTx>
- implements GridCacheFuture<IgniteInternalTx> {
- /** Logger reference. */
- protected static final AtomicReference<IgniteLogger> logRef = new AtomicReference<>();
-
- /** */
- private static final IgniteReducer<IgniteInternalTx, IgniteInternalTx> REDUCER =
- new IgniteReducer<IgniteInternalTx, IgniteInternalTx>() {
- @Override public boolean collect(IgniteInternalTx e) {
- return true;
- }
-
- @Override public IgniteInternalTx reduce() {
- // Nothing to aggregate.
- return null;
- }
- };
-
- /** Logger. */
- protected static IgniteLogger log;
-
- /** Context. */
- protected GridCacheSharedContext<?, ?> cctx;
-
- /** Future ID. */
- protected IgniteUuid futId;
-
- /** Transaction. */
- @GridToStringInclude
- protected GridNearTxLocal tx;
-
- /** Error. */
- @GridToStringExclude
- protected AtomicReference<Throwable> err = new AtomicReference<>(null);
-
- /** Trackable flag. */
- protected boolean trackable = true;
-
- /** Full information about transaction nodes mapping. */
- protected GridDhtTxMapping txMapping;
-
- /**
- * @param cctx Context.
- * @param tx Transaction.
- */
- public GridNearTxPrepareFutureAdapter(GridCacheSharedContext cctx, final GridNearTxLocal tx) {
- super(cctx.kernalContext(), REDUCER);
-
- assert cctx != null;
- assert tx != null;
-
- this.cctx = cctx;
- this.tx = tx;
-
- futId = IgniteUuid.randomUuid();
-
- if (log == null)
- log = U.logger(cctx.kernalContext(), logRef, GridNearTxPrepareFutureAdapter.class);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteUuid futureId() {
- return futId;
- }
-
- /** {@inheritDoc} */
- @Override public GridCacheVersion version() {
- return tx.xidVersion();
- }
-
- /** {@inheritDoc} */
- @Override public void markNotTrackable() {
- trackable = false;
- }
-
- /** {@inheritDoc} */
- @Override public boolean trackable() {
- return trackable;
- }
-
- /**
- * Prepares transaction.
- */
- public abstract void prepare();
-
- /**
- * @param nodeId Sender.
- * @param res Result.
- */
- public abstract void onResult(UUID nodeId, GridNearTxPrepareResponse res);
-
- /**
- * Checks if mapped transaction can be committed on one phase.
- * One-phase commit can be done if transaction maps to one primary node and not more than one backup.
- */
- protected final void checkOnePhase() {
- if (tx.storeUsed())
- return;
-
- Map<UUID, Collection<UUID>> map = txMapping.transactionNodes();
-
- if (map.size() == 1) {
- Map.Entry<UUID, Collection<UUID>> entry = F.firstEntry(map);
-
- assert entry != null;
-
- Collection<UUID> backups = entry.getValue();
-
- if (backups.size() <= 1)
- tx.onePhaseCommit(true);
- }
- }
-
- /**
- * @param m Mapping.
- * @param res Response.
- */
- protected final void onPrepareResponse(GridDistributedTxMapping m, GridNearTxPrepareResponse res) {
- if (res == null)
- return;
-
- assert res.error() == null : res;
- assert F.isEmpty(res.invalidPartitions()) : res;
-
- for (Map.Entry<IgniteTxKey, CacheVersionedValue> entry : res.ownedValues().entrySet()) {
- IgniteTxEntry txEntry = tx.entry(entry.getKey());
-
- assert txEntry != null;
-
- GridCacheContext cacheCtx = txEntry.context();
-
- while (true) {
- try {
- if (cacheCtx.isNear()) {
- GridNearCacheEntry nearEntry = (GridNearCacheEntry)txEntry.cached();
-
- CacheVersionedValue tup = entry.getValue();
-
- nearEntry.resetFromPrimary(tup.value(), tx.xidVersion(),
- tup.version(), m.node().id(), tx.topologyVersion());
- }
- else if (txEntry.cached().detached()) {
- GridDhtDetachedCacheEntry detachedEntry = (GridDhtDetachedCacheEntry)txEntry.cached();
-
- CacheVersionedValue tup = entry.getValue();
-
- detachedEntry.resetFromPrimary(tup.value(), tx.xidVersion());
- }
-
- break;
- }
- catch (GridCacheEntryRemovedException ignored) {
- // Retry.
- }
- }
- }
-
- tx.implicitSingleResult(res.returnValue());
-
- for (IgniteTxKey key : res.filterFailedKeys()) {
- IgniteTxEntry txEntry = tx.entry(key);
-
- assert txEntry != null : "Missing tx entry for write key: " + key;
-
- txEntry.op(NOOP);
-
- assert txEntry.context() != null;
-
- ExpiryPolicy expiry = txEntry.context().expiryForTxEntry(txEntry);
-
- if (expiry != null)
- txEntry.ttl(CU.toTtl(expiry.getExpiryForAccess()));
- }
-
- if (!m.empty()) {
- // Register DHT version.
- tx.addDhtVersion(m.node().id(), res.dhtVersion());
-
- m.dhtVersion(res.dhtVersion());
-
- if (m.near())
- tx.readyNearLocks(m, res.pending(), res.committedVersions(), res.rolledbackVersions());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
index a08637d..f0587ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
@@ -88,6 +88,8 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
* @param tx Transaction.
* @param reads Read entries.
* @param writes Write entries.
+ * @param grpLockKey Group lock key if preparing group-lock transaction.
+ * @param partLock {@code True} if preparing group-lock transaction with partition lock.
* @param near {@code True} if mapping is for near caches.
* @param txNodes Transaction nodes mapping.
* @param last {@code True} if this last prepare request for node.
@@ -101,6 +103,8 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
IgniteInternalTx tx,
Collection<IgniteTxEntry> reads,
Collection<IgniteTxEntry> writes,
+ IgniteTxKey grpLockKey,
+ boolean partLock,
boolean near,
Map<UUID, Collection<UUID>> txNodes,
boolean last,
@@ -112,7 +116,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
@Nullable UUID subjId,
int taskNameHash
) {
- super(tx, reads, writes, txNodes, onePhaseCommit);
+ super(tx, reads, writes, grpLockKey, partLock, txNodes, onePhaseCommit);
assert futId != null;
@@ -266,67 +270,67 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
}
switch (writer.state()) {
- case 23:
+ case 25:
if (!writer.writeBoolean("explicitLock", explicitLock))
return false;
writer.incrementState();
- case 24:
+ case 26:
if (!writer.writeIgniteUuid("futId", futId))
return false;
writer.incrementState();
- case 25:
+ case 27:
if (!writer.writeBoolean("implicitSingle", implicitSingle))
return false;
writer.incrementState();
- case 26:
+ case 28:
if (!writer.writeBoolean("last", last))
return false;
writer.incrementState();
- case 27:
+ case 29:
if (!writer.writeCollection("lastBackups", lastBackups, MessageCollectionItemType.UUID))
return false;
writer.incrementState();
- case 28:
+ case 30:
if (!writer.writeIgniteUuid("miniId", miniId))
return false;
writer.incrementState();
- case 29:
+ case 31:
if (!writer.writeBoolean("near", near))
return false;
writer.incrementState();
- case 30:
+ case 32:
if (!writer.writeBoolean("retVal", retVal))
return false;
writer.incrementState();
- case 31:
+ case 33:
if (!writer.writeUuid("subjId", subjId))
return false;
writer.incrementState();
- case 32:
+ case 34:
if (!writer.writeInt("taskNameHash", taskNameHash))
return false;
writer.incrementState();
- case 33:
+ case 35:
if (!writer.writeMessage("topVer", topVer))
return false;
@@ -348,7 +352,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
return false;
switch (reader.state()) {
- case 23:
+ case 25:
explicitLock = reader.readBoolean("explicitLock");
if (!reader.isLastRead())
@@ -356,7 +360,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 24:
+ case 26:
futId = reader.readIgniteUuid("futId");
if (!reader.isLastRead())
@@ -364,7 +368,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 25:
+ case 27:
implicitSingle = reader.readBoolean("implicitSingle");
if (!reader.isLastRead())
@@ -372,7 +376,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 26:
+ case 28:
last = reader.readBoolean("last");
if (!reader.isLastRead())
@@ -380,7 +384,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 27:
+ case 29:
lastBackups = reader.readCollection("lastBackups", MessageCollectionItemType.UUID);
if (!reader.isLastRead())
@@ -388,7 +392,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 28:
+ case 30:
miniId = reader.readIgniteUuid("miniId");
if (!reader.isLastRead())
@@ -396,7 +400,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 29:
+ case 31:
near = reader.readBoolean("near");
if (!reader.isLastRead())
@@ -404,7 +408,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 30:
+ case 32:
retVal = reader.readBoolean("retVal");
if (!reader.isLastRead())
@@ -412,7 +416,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 31:
+ case 33:
subjId = reader.readUuid("subjId");
if (!reader.isLastRead())
@@ -420,7 +424,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 32:
+ case 34:
taskNameHash = reader.readInt("taskNameHash");
if (!reader.isLastRead())
@@ -428,7 +432,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
reader.incrementState();
- case 33:
+ case 35:
topVer = reader.readMessage("topVer");
if (!reader.isLastRead())
@@ -448,7 +452,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 34;
+ return 36;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
index 49283cb..b6b6017 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
@@ -51,6 +51,9 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
/** Owned versions. */
private Map<IgniteTxKey, GridCacheVersion> owned;
+ /** Group lock flag. */
+ private boolean grpLock;
+
/**
* Empty constructor required for {@link Externalizable}.
*/
@@ -75,6 +78,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
* @param writeEntries Write entries.
* @param ctx Cache registry.
* @param txSize Expected transaction size.
+ * @param grpLockKey Group lock key if this is a group-lock transaction.
* @throws IgniteCheckedException If unmarshalling failed.
*/
public GridNearTxRemote(
@@ -93,11 +97,12 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
long timeout,
Collection<IgniteTxEntry> writeEntries,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
@Nullable UUID subjId,
int taskNameHash
) throws IgniteCheckedException {
super(ctx, nodeId, rmtThreadId, xidVer, commitVer, sys, plc, concurrency, isolation, invalidate, timeout,
- txSize, subjId, taskNameHash);
+ txSize, grpLockKey, subjId, taskNameHash);
assert nearNodeId != null;
@@ -133,6 +138,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
* @param timeout Timeout.
* @param ctx Cache registry.
* @param txSize Expected transaction size.
+ * @param grpLockKey Collection of group lock keys if this is a group-lock transaction.
*/
public GridNearTxRemote(
GridCacheSharedContext ctx,
@@ -149,11 +155,12 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
boolean invalidate,
long timeout,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
@Nullable UUID subjId,
int taskNameHash
) {
super(ctx, nodeId, rmtThreadId, xidVer, commitVer, sys, plc, concurrency, isolation, invalidate, timeout,
- txSize, subjId, taskNameHash);
+ txSize, grpLockKey, subjId, taskNameHash);
assert nearNodeId != null;
@@ -185,6 +192,19 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
}
/**
+ * Marks near local transaction as group lock. Note that near remote transaction may be
+ * marked as group lock even if it does not contain any locked key.
+ */
+ public void markGroupLock() {
+ grpLock = true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean groupLock() {
+ return grpLock || super.groupLock();
+ }
+
+ /**
* @return Near transaction ID.
*/
@Override public GridCacheVersion nearXidVersion() {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
index ea59f1f..84d4c90 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
@@ -29,9 +29,6 @@ import static org.apache.ignite.events.EventType.*;
*/
@SuppressWarnings({"NonPrivateFieldAccessedInSynchronizedContext", "TooBroadScope"})
public class GridLocalCacheEntry extends GridCacheMapEntry {
- /** Off-heap value pointer. */
- private long valPtr;
-
/**
* @param ctx Cache registry.
* @param key Cache key.
@@ -387,19 +384,4 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
return doomed != null;
}
-
- /** {@inheritDoc} */
- @Override protected boolean hasOffHeapPointer() {
- return valPtr != 0;
- }
-
- /** {@inheritDoc} */
- @Override protected long offHeapPointer() {
- return valPtr;
- }
-
- /** {@inheritDoc} */
- @Override protected void offHeapPointer(long valPtr) {
- this.valPtr = valPtr;
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java
index 5f877ec..8dc07cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java
@@ -284,6 +284,16 @@ public interface IgniteInternalTx extends AutoCloseable, GridTimeoutObject {
public boolean empty();
/**
+ * @return {@code True} if transaction group-locked.
+ */
+ public boolean groupLock();
+
+ /**
+ * @return Group lock key if {@link #groupLock()} is {@code true}.
+ */
+ @Nullable public IgniteTxKey groupLockKey();
+
+ /**
* @return {@code True} if preparing flag was set with this call.
*/
public boolean markPreparing();
@@ -541,7 +551,7 @@ public interface IgniteInternalTx extends AutoCloseable, GridTimeoutObject {
*
* @return Future for prepare step.
*/
- public IgniteInternalFuture<?> prepareAsync();
+ public IgniteInternalFuture<IgniteInternalTx> prepareAsync();
/**
* @param endVer End version (a.k.a. <tt>'tnc'</tt> or <tt>'transaction number counter'</tt>)
@@ -570,7 +580,7 @@ public interface IgniteInternalTx extends AutoCloseable, GridTimeoutObject {
/**
* @return Future for transaction prepare if prepare is in progress.
*/
- @Nullable public IgniteInternalFuture<?> currentPrepareFuture();
+ @Nullable public IgniteInternalFuture<IgniteInternalTx> currentPrepareFuture();
/**
* @param state Transaction state.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
index 99907e4..044c3d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
@@ -160,7 +160,9 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
isolation,
timeout,
true,
- txSize
+ txSize,
+ /** group lock keys */null,
+ /** partition lock */false
);
assert tx != null;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index eb8825e..82d68b3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -179,6 +179,9 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
/** */
protected int txSize;
+ /** Group lock key, if any. */
+ protected IgniteTxKey grpLockKey;
+
/** */
@GridToStringExclude
private AtomicReference<GridFutureAdapter<IgniteInternalTx>> finFut = new AtomicReference<>();
@@ -230,6 +233,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
* @param isolation Isolation.
* @param timeout Timeout.
* @param txSize Transaction size.
+ * @param grpLockKey Group lock key if this is group-lock transaction.
*/
protected IgniteTxAdapter(
GridCacheSharedContext<?, ?> cctx,
@@ -245,6 +249,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
boolean invalidate,
boolean storeEnabled,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
@Nullable UUID subjId,
int taskNameHash
) {
@@ -264,6 +269,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
this.invalidate = invalidate;
this.storeEnabled = storeEnabled;
this.txSize = txSize;
+ this.grpLockKey = grpLockKey;
this.subjId = subjId;
this.taskNameHash = taskNameHash;
@@ -288,6 +294,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
* @param isolation Isolation.
* @param timeout Timeout.
* @param txSize Transaction size.
+ * @param grpLockKey Group lock key if this is group-lock transaction.
*/
protected IgniteTxAdapter(
GridCacheSharedContext<?, ?> cctx,
@@ -301,6 +308,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
TransactionIsolation isolation,
long timeout,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
@Nullable UUID subjId,
int taskNameHash
) {
@@ -315,6 +323,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
this.isolation = isolation;
this.timeout = timeout;
this.txSize = txSize;
+ this.grpLockKey = grpLockKey;
this.subjId = subjId;
this.taskNameHash = taskNameHash;
@@ -378,7 +387,30 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
/** {@inheritDoc} */
@Override public Collection<IgniteTxEntry> optimisticLockEntries() {
- return writeEntries();
+ if (!groupLock())
+ return writeEntries();
+ else {
+ if (!F.isEmpty(invalidParts)) {
+ assert invalidParts.size() == 1 : "Only one partition expected for group lock transaction " +
+ "[tx=" + this + ", invalidParts=" + invalidParts + ']';
+ assert groupLockEntry() == null : "Group lock key should be rejected " +
+ "[tx=" + this + ", groupLockEntry=" + groupLockEntry() + ']';
+ assert F.isEmpty(writeMap()) : "All entries should be rejected for group lock transaction " +
+ "[tx=" + this + ", writes=" + writeMap() + ']';
+
+ return Collections.emptyList();
+ }
+
+ IgniteTxEntry grpLockEntry = groupLockEntry();
+
+ assert grpLockEntry != null || (near() && !local()):
+ "Group lock entry was not enlisted into transaction [tx=" + this +
+ ", grpLockKey=" + groupLockKey() + ']';
+
+ return grpLockEntry == null ?
+ Collections.<IgniteTxEntry>emptyList() :
+ Collections.singletonList(grpLockEntry);
+ }
}
/** {@inheritDoc} */
@@ -450,6 +482,16 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
cctx.tm().uncommitTx(this);
}
+ /**
+ * This method uses unchecked assignment to cast group lock key entry to transaction generic signature.
+ *
+ * @return Group lock tx entry.
+ */
+ @SuppressWarnings("unchecked")
+ public IgniteTxEntry groupLockEntry() {
+ return this.entry(groupLockKey());
+ }
+
/** {@inheritDoc} */
@Override public UUID otherNodeId() {
return null;
@@ -561,6 +603,16 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
public abstract boolean isStarted();
/** {@inheritDoc} */
+ @Override public boolean groupLock() {
+ return grpLockKey != null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteTxKey groupLockKey() {
+ return grpLockKey;
+ }
+
+ /** {@inheritDoc} */
@Override public int size() {
return txSize;
}
@@ -746,6 +798,9 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
GridCacheVersion explicit = txEntry == null ? null : txEntry.explicitVersion();
+ assert !txEntry.groupLockEntry() || groupLock() : "Can not have group-locked tx entries in " +
+ "non-group-lock transactions [txEntry=" + txEntry + ", tx=" + this + ']';
+
return local() && !cacheCtx.isDht() ?
entry.lockedByThread(threadId()) || (explicit != null && entry.lockedBy(explicit)) :
// If candidate is not there, then lock was explicit.
@@ -762,6 +817,9 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
GridCacheVersion explicit = txEntry == null ? null : txEntry.explicitVersion();
+ assert !txEntry.groupLockEntry() || groupLock() : "Can not have group-locked tx entries in " +
+ "non-group-lock transactions [txEntry=" + txEntry + ", tx=" + this + ']';
+
return local() && !cacheCtx.isDht() ?
entry.lockedByThreadUnsafe(threadId()) || (explicit != null && entry.lockedByUnsafe(explicit)) :
// If candidate is not there, then lock was explicit.
@@ -950,7 +1008,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
}
/** {@inheritDoc} */
- @Nullable @Override public IgniteInternalFuture<?> currentPrepareFuture() {
+ @Nullable @Override public IgniteInternalFuture<IgniteInternalTx> currentPrepareFuture() {
return null;
}
@@ -1496,7 +1554,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
/** {@inheritDoc} */
@Override public String toString() {
return GridToStringBuilder.toString(IgniteTxAdapter.class, this,
- "duration", (U.currentTimeMillis() - startTime) + "ms",
+ "duration", (U.currentTimeMillis() - startTime) + "ms", "grpLock", groupLock(),
"onePhaseCommit", onePhaseCommit);
}
@@ -1721,6 +1779,16 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
}
/** {@inheritDoc} */
+ @Override public boolean groupLock() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public IgniteTxKey groupLockKey() {
+ throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
+ }
+
+ /** {@inheritDoc} */
@Override public boolean markPreparing() {
throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index aff2f40..6d4fed6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -137,6 +137,9 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
@GridDirectTransient
private boolean locMapped;
+ /** Group lock entry flag. */
+ private boolean grpLock;
+
/** Expiry policy. */
@GridDirectTransient
private ExpiryPolicy expiryPlc;
@@ -274,6 +277,22 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
}
/**
+ * @return {@code True} if this entry was added in group lock transaction and
+ * this is not a group lock entry.
+ */
+ public boolean groupLockEntry() {
+ return grpLock;
+ }
+
+ /**
+ * @param grpLock {@code True} if this entry was added in group lock transaction and
+ * this is not a group lock entry.
+ */
+ public void groupLockEntry(boolean grpLock) {
+ this.grpLock = grpLock;
+ }
+
+ /**
* @param ctx Context.
* @return Clean copy of this entry.
*/
@@ -292,6 +311,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
cp.ttl = ttl;
cp.conflictExpireTime = conflictExpireTime;
cp.explicitVer = explicitVer;
+ cp.grpLock = grpLock;
cp.conflictVer = conflictVer;
cp.expiryPlc = expiryPlc;
cp.flags = flags;
@@ -831,24 +851,30 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
writer.incrementState();
case 7:
- if (!writer.writeMessage("key", key))
+ if (!writer.writeBoolean("grpLock", grpLock))
return false;
writer.incrementState();
case 8:
- if (!writer.writeByteBuffer("transformClosBytes", transformClosBytes))
+ if (!writer.writeMessage("key", key))
return false;
writer.incrementState();
case 9:
- if (!writer.writeLong("ttl", ttl))
+ if (!writer.writeByteBuffer("transformClosBytes", transformClosBytes))
return false;
writer.incrementState();
case 10:
+ if (!writer.writeLong("ttl", ttl))
+ return false;
+
+ writer.incrementState();
+
+ case 11:
if (!writer.writeMessage("val", val))
return false;
@@ -924,7 +950,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
reader.incrementState();
case 7:
- key = reader.readMessage("key");
+ grpLock = reader.readBoolean("grpLock");
if (!reader.isLastRead())
return false;
@@ -932,7 +958,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
reader.incrementState();
case 8:
- transformClosBytes = reader.readByteBuffer("transformClosBytes");
+ key = reader.readMessage("key");
if (!reader.isLastRead())
return false;
@@ -940,7 +966,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
reader.incrementState();
case 9:
- ttl = reader.readLong("ttl");
+ transformClosBytes = reader.readByteBuffer("transformClosBytes");
if (!reader.isLastRead())
return false;
@@ -948,6 +974,14 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
reader.incrementState();
case 10:
+ ttl = reader.readLong("ttl");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 11:
val = reader.readMessage("val");
if (!reader.isLastRead())
@@ -967,7 +1001,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 11;
+ return 12;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index f466bf2..af75fb8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.util.future.*;
import org.apache.ignite.internal.util.lang.*;
import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
import org.jetbrains.annotations.*;
import java.util.*;
@@ -57,9 +58,9 @@ public class IgniteTxHandler {
* @param req Request.
* @return Prepare future.
*/
- public IgniteInternalFuture<?> processNearTxPrepareRequest(final UUID nearNodeId,
+ public IgniteInternalFuture<IgniteInternalTx> processNearTxPrepareRequest(final UUID nearNodeId,
final GridNearTxPrepareRequest req) {
- return prepareTx(nearNodeId, null, req);
+ return prepareTx(nearNodeId, null, req, null);
}
/**
@@ -137,28 +138,32 @@ public class IgniteTxHandler {
* @param nearNodeId Near node ID that initiated transaction.
* @param locTx Optional local transaction.
* @param req Near prepare request.
+ * @param completeCb Completion callback.
* @return Future for transaction.
*/
- public IgniteInternalFuture<GridNearTxPrepareResponse> prepareTx(
+ public IgniteInternalFuture<IgniteInternalTx> prepareTx(
UUID nearNodeId,
@Nullable GridNearTxLocal locTx,
- GridNearTxPrepareRequest req
+ GridNearTxPrepareRequest req,
+ @Nullable IgniteInClosure<GridNearTxPrepareResponse> completeCb
) {
assert nearNodeId != null;
assert req != null;
if (locTx != null) {
+ assert completeCb != null;
+
if (req.near()) {
// Make sure not to provide Near entries to DHT cache.
req.cloneEntries();
- return prepareNearTx(nearNodeId, req);
+ return prepareNearTx(nearNodeId, req, completeCb);
}
else
- return prepareColocatedTx(locTx, req);
+ return prepareColocatedTx(locTx, req, completeCb);
}
else
- return prepareNearTx(nearNodeId, req);
+ return prepareNearTx(nearNodeId, req, null);
}
/**
@@ -166,27 +171,30 @@ public class IgniteTxHandler {
*
* @param locTx Local transaction.
* @param req Near prepare request.
+ * @param completeCb Completion callback.
* @return Prepare future.
*/
- private IgniteInternalFuture<GridNearTxPrepareResponse> prepareColocatedTx(
+ private IgniteInternalFuture<IgniteInternalTx> prepareColocatedTx(
final GridNearTxLocal locTx,
- final GridNearTxPrepareRequest req
+ final GridNearTxPrepareRequest req,
+ final IgniteInClosure<GridNearTxPrepareResponse> completeCb
) {
IgniteInternalFuture<Object> fut = new GridFinishedFuture<>(); // TODO force preload keys.
return new GridEmbeddedFuture<>(
fut,
- new C2<Object, Exception, IgniteInternalFuture<GridNearTxPrepareResponse>>() {
- @Override public IgniteInternalFuture<GridNearTxPrepareResponse> apply(Object o, Exception ex) {
+ new C2<Object, Exception, IgniteInternalFuture<IgniteInternalTx>>() {
+ @Override public IgniteInternalFuture<IgniteInternalTx> apply(Object o, Exception ex) {
if (ex != null)
throw new GridClosureException(ex);
- IgniteInternalFuture<GridNearTxPrepareResponse> fut = locTx.prepareAsyncLocal(
+ IgniteInternalFuture<IgniteInternalTx> fut = locTx.prepareAsyncLocal(
req.reads(),
req.writes(),
req.transactionNodes(),
req.last(),
- req.lastBackups());
+ req.lastBackups(),
+ completeCb);
if (locTx.isRollbackOnly())
locTx.rollbackAsync();
@@ -194,16 +202,18 @@ public class IgniteTxHandler {
return fut;
}
},
- new C2<GridNearTxPrepareResponse, Exception, GridNearTxPrepareResponse>() {
- @Nullable @Override public GridNearTxPrepareResponse apply(GridNearTxPrepareResponse res, Exception e) {
+ new C2<IgniteInternalTx, Exception, IgniteInternalTx>() {
+ @Nullable @Override public IgniteInternalTx apply(IgniteInternalTx tx, Exception e) {
if (e != null) {
- locTx.setRollbackOnly(); // Just in case.
+ // tx can be null of exception occurred.
+ if (tx != null)
+ tx.setRollbackOnly(); // Just in case.
if (!(e instanceof IgniteTxOptimisticCheckedException))
- U.error(log, "Failed to prepare transaction: " + locTx, e);
+ U.error(log, "Failed to prepare DHT transaction: " + tx, e);
}
- return res;
+ return tx;
}
}
);
@@ -214,11 +224,13 @@ public class IgniteTxHandler {
*
* @param nearNodeId Near node ID that initiated transaction.
* @param req Near prepare request.
+ * @param completeCb Completion callback.
* @return Prepare future.
*/
- private IgniteInternalFuture<GridNearTxPrepareResponse> prepareNearTx(
+ private IgniteInternalFuture<IgniteInternalTx> prepareNearTx(
final UUID nearNodeId,
- final GridNearTxPrepareRequest req
+ final GridNearTxPrepareRequest req,
+ IgniteInClosure<GridNearTxPrepareResponse> completeCb
) {
ClusterNode nearNode = ctx.node(nearNodeId);
@@ -271,6 +283,8 @@ public class IgniteTxHandler {
req.isInvalidate(),
false,
req.txSize(),
+ req.groupLockKey(),
+ req.partitionLock(),
req.transactionNodes(),
req.subjectId(),
req.taskNameHash()
@@ -301,7 +315,7 @@ public class IgniteTxHandler {
if (req.returnValue())
tx.needReturnValue(true);
- IgniteInternalFuture<GridNearTxPrepareResponse> fut = tx.prepareAsync(
+ IgniteInternalFuture<IgniteInternalTx> fut = tx.prepareAsync(
req.reads(),
req.writes(),
req.dhtVersions(),
@@ -309,7 +323,8 @@ public class IgniteTxHandler {
req.miniId(),
req.transactionNodes(),
req.last(),
- req.lastBackups());
+ req.lastBackups(),
+ completeCb);
if (tx.isRollbackOnly()) {
try {
@@ -322,8 +337,8 @@ public class IgniteTxHandler {
final GridDhtTxLocal tx0 = tx;
- fut.listen(new CI1<IgniteInternalFuture<?>>() {
- @Override public void apply(IgniteInternalFuture<?> txFut) {
+ fut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
+ @Override public void apply(IgniteInternalFuture<IgniteInternalTx> txFut) {
try {
txFut.get();
}
@@ -339,7 +354,7 @@ public class IgniteTxHandler {
return fut;
}
else
- return new GridFinishedFuture<>((GridNearTxPrepareResponse)null);
+ return new GridFinishedFuture<>((IgniteInternalTx)null);
}
/**
@@ -347,7 +362,7 @@ public class IgniteTxHandler {
* @param res Response.
*/
private void processNearTxPrepareResponse(UUID nodeId, GridNearTxPrepareResponse res) {
- GridNearTxPrepareFutureAdapter fut = (GridNearTxPrepareFutureAdapter)ctx.mvcc()
+ GridNearTxPrepareFuture fut = (GridNearTxPrepareFuture)ctx.mvcc()
.<IgniteInternalTx>future(res.version(), res.futureId());
if (fut == null) {
@@ -384,7 +399,8 @@ public class IgniteTxHandler {
* @param res Response.
*/
private void processDhtTxPrepareResponse(UUID nodeId, GridDhtTxPrepareResponse res) {
- GridDhtTxPrepareFuture fut = (GridDhtTxPrepareFuture)ctx.mvcc().future(res.version(), res.futureId());
+ GridDhtTxPrepareFuture fut = (GridDhtTxPrepareFuture)ctx.mvcc().
+ <IgniteInternalTx>future(res.version(), res.futureId());
if (fut == null) {
if (log.isDebugEnabled())
@@ -552,6 +568,8 @@ public class IgniteTxHandler {
req.isInvalidate(),
req.storeEnabled(),
req.txSize(),
+ req.groupLockKey(),
+ false,
null,
req.subjectId(),
req.taskNameHash()));
@@ -998,6 +1016,7 @@ public class IgniteTxHandler {
req.isInvalidate(),
req.timeout(),
req.writes() != null ? Math.max(req.writes().size(), req.txSize()) : req.txSize(),
+ req.groupLockKey(),
req.nearXidVersion(),
req.transactionNodes(),
req.subjectId(),
@@ -1131,6 +1150,7 @@ public class IgniteTxHandler {
req.timeout(),
req.nearWrites(),
req.txSize(),
+ req.groupLockKey(),
req.subjectId(),
req.taskNameHash()
);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index 609108f..3c855ec 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -86,6 +86,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
/** Base for completed versions. */
private GridCacheVersion completedBase;
+ /** Flag indicating partition lock in group lock transaction. */
+ private boolean partLock;
+
/** Flag indicating that transformed values should be sent to remote nodes. */
private boolean sndTransformedVals;
@@ -120,6 +123,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
* @param isolation Isolation.
* @param timeout Timeout.
* @param txSize Expected transaction size.
+ * @param grpLockKey Group lock key if this is a group-lock transaction.
+ * @param partLock {@code True} if this is a group-lock transaction and lock is acquired for whole partition.
*/
protected IgniteTxLocalAdapter(
GridCacheSharedContext cctx,
@@ -134,11 +139,17 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
boolean invalidate,
boolean storeEnabled,
int txSize,
+ @Nullable IgniteTxKey grpLockKey,
+ boolean partLock,
@Nullable UUID subjId,
int taskNameHash
) {
super(cctx, xidVer, implicit, implicitSingle, /*local*/true, sys, plc, concurrency, isolation, timeout,
- invalidate, storeEnabled, txSize, subjId, taskNameHash);
+ invalidate, storeEnabled, txSize, grpLockKey, subjId, taskNameHash);
+
+ assert !partLock || grpLockKey != null;
+
+ this.partLock = partLock;
minVer = xidVer;
}
@@ -171,6 +182,11 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
}
/** {@inheritDoc} */
+ @Override public boolean partitionLock() {
+ return partLock;
+ }
+
+ /** {@inheritDoc} */
@Override public Throwable commitError() {
return commitErr.get();
}
@@ -483,7 +499,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
CacheStoreManager store = store();
if (store != null && store.isWriteThrough() && storeEnabled() &&
- !internal() && (near() || store.isWriteToStoreFromDht())) {
+ (!internal() || groupLock()) && (near() || store.isWriteToStoreFromDht())) {
try {
if (writeEntries != null) {
Map<Object, IgniteBiTuple<Object, GridCacheVersion>> putMap = null;
@@ -663,6 +679,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
if (!empty || colocated())
cctx.tm().addCommittedTx(this);
+ if (groupLock())
+ addGroupTxMapping(writeSet());
+
if (!empty) {
batchStoreCommit(writeMap().values());
@@ -890,6 +909,10 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
log.debug("Ignoring READ entry when committing: " + txEntry);
}
else {
+ assert !groupLock() || txEntry.groupLockEntry() || ownsLock(txEntry.cached()):
+ "Transaction does not own lock for group lock entry during commit [tx=" +
+ this + ", txEntry=" + txEntry + ']';
+
if (conflictCtx == null || !conflictCtx.isUseOld()) {
if (txEntry.ttl() != CU.TTL_NOT_CHANGED)
cached.updateTtl(null, txEntry.ttl());
@@ -904,7 +927,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
// we are not changing obsolete entries.
// (innerSet and innerRemove will throw an exception
// if an entry is obsolete).
- if (txEntry.op() != READ)
+ if (txEntry.op() != READ && !txEntry.groupLockEntry())
checkCommitLocks(cached);
// Break out of while loop.
@@ -973,7 +996,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
else {
CacheStoreManager store = store();
- if (store != null && !internal()) {
+ if (store != null && (!internal() || groupLock())) {
try {
store.sessionEnd(this, true);
}
@@ -1079,7 +1102,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
CacheStoreManager store = store();
if (store != null && (near() || store.isWriteToStoreFromDht())) {
- if (!internal())
+ if (!internal() || groupLock())
store.sessionEnd(this, false);
}
}
@@ -1129,6 +1152,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
cacheCtx.checkSecurity(SecurityPermission.CACHE_READ);
+ groupLockSanityCheck(cacheCtx, keys);
+
boolean single = keysCnt == 1;
Collection<KeyCacheObject> lockKeys = null;
@@ -1160,7 +1185,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
cacheCtx.addResult(map, key, val, skipVals, keepCacheObjects, deserializePortable, false);
}
else {
- assert txEntry.op() == TRANSFORM;
+ assert txEntry.op() == TRANSFORM || (groupLock() && !txEntry.groupLockEntry());
while (true) {
try {
@@ -1238,7 +1263,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
CacheObject val = null;
- if (!pessimistic() || readCommitted() && !skipVals) {
+ if (!pessimistic() || readCommitted() || groupLock() && !skipVals) {
IgniteCacheExpiryPolicy accessPlc =
optimistic() ? accessPolicy(cacheCtx, txKey, expiryPlc) : null;
@@ -1286,6 +1311,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
null,
skipStore);
+ if (groupLock())
+ txEntry.groupLockEntry(true);
// As optimization, mark as checked immediately
// for non-pessimistic if value is not null.
@@ -1500,7 +1527,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
nextVer = cctx.versions().next(topologyVersion());
while (true) {
- assert txEntry != null || readCommitted() || skipVals;
+ assert txEntry != null || readCommitted() || groupLock() || skipVals;
GridCacheEntryEx e = txEntry == null ? entryEx(cacheCtx, txKey) : txEntry.cached();
@@ -1517,7 +1544,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
log.debug("Got removed entry in transaction getAll method " +
"(will try again): " + e);
- if (pessimistic() && !readCommitted() && !isRollbackOnly()) {
+ if (pessimistic() && !readCommitted() && !isRollbackOnly() &&
+ (!groupLock() || F.eq(e.key(), groupLockKey()))) {
U.error(log, "Inconsistent transaction state (entry got removed while " +
"holding lock) [entry=" + e + ", tx=" + IgniteTxLocalAdapter.this + "]");
@@ -1535,7 +1563,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
// In pessimistic mode, we should always be able to set.
assert set || !pessimistic();
- if (readCommitted() || skipVals) {
+ if (readCommitted() || groupLock() || skipVals) {
cacheCtx.evicts().touch(e, topologyVersion());
if (visibleVal != null) {
@@ -1626,7 +1654,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
return new GridFinishedFuture<>(retMap);
// Handle locks.
- if (pessimistic() && !readCommitted() && !skipVals) {
+ if (pessimistic() && !readCommitted() && !groupLock() && !skipVals) {
if (expiryPlc == null)
expiryPlc = cacheCtx.expiry();
@@ -1732,7 +1760,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
}
}
- if (!missed.isEmpty() && cacheCtx.isLocal()) {
+ if (!missed.isEmpty() && (cacheCtx.isReplicated() || cacheCtx.isLocal())) {
return checkMissed(cacheCtx,
retMap,
missed,
@@ -1783,7 +1811,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
}
}
else {
- assert optimistic() || readCommitted() || skipVals;
+ assert optimistic() || readCommitted() || groupLock() || skipVals;
final Collection<KeyCacheObject> redos = new ArrayList<>();
@@ -2008,6 +2036,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
if (invokeMap != null)
transform = true;
+ groupLockSanityCheck(cacheCtx, keys);
+
for (Object key : keys) {
if (key == null) {
rollback();
@@ -2164,9 +2194,12 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
if (!implicit() && readCommitted() && !cacheCtx.offheapTiered())
cacheCtx.evicts().touch(entry, topologyVersion());
+ if (groupLock() && !lockOnly)
+ txEntry.groupLockEntry(true);
+
enlisted.add(cacheKey);
- if (!pessimistic() && !implicit()) {
+ if ((!pessimistic() && !implicit()) || (groupLock() && !lockOnly)) {
txEntry.markValid();
if (old == null) {
@@ -2611,7 +2644,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
null,
opCtx != null && opCtx.skipStore());
- if (pessimistic()) {
+ if (pessimistic() && !groupLock()) {
// Loose all skipped.
final Set<KeyCacheObject> loaded = loadFut.get();
@@ -2834,7 +2867,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
// Acquire locks only after having added operation to the write set.
// Otherwise, during rollback we will not know whether locks need
// to be rolled back.
- if (pessimistic()) {
+ if (pessimistic() && !groupLock()) {
// Loose all skipped.
final Collection<KeyCacheObject> passedKeys = F.view(enlisted, F0.notIn(loadFut.get()));
@@ -2952,6 +2985,108 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
}
/**
+ * Adds key mapping to transaction.
+ * @param keys Keys to add.
+ */
+ protected void addGroupTxMapping(Collection<IgniteTxKey> keys) {
+ // No-op. This method is overriden in transactions that store key to remote node mapping
+ // for commit.
+ }
+
+ /**
+ * Checks that affinity keys are enlisted in group transaction on start.
+ *
+ * @param cacheCtx Cache context.
+ * @param keys Keys to check.
+ * @throws IgniteCheckedException If sanity check failed.
+ */
+ private <K> void groupLockSanityCheck(GridCacheContext cacheCtx, Iterable<? extends K> keys)
+ throws IgniteCheckedException
+ {
+ if (groupLock() && cctx.kernalContext().config().isCacheSanityCheckEnabled()) {
+ // Note that affinity is called without mapper on purpose.
+ int affinityPart = cacheCtx.config().getAffinity().partition(grpLockKey.key());
+
+ for (K key : keys) {
+ if (partitionLock()) {
+ int part = cacheCtx.affinity().partition(key);
+
+ if (affinityPart != part)
+ throw new IgniteCheckedException("Failed to enlist key into group-lock transaction (given " +
+ "key does not belong to locked partition) [key=" + key + ", affinityPart=" + affinityPart +
+ ", part=" + part + ", groupLockKey=" + grpLockKey + ']');
+ }
+ else {
+ KeyCacheObject cacheKey =
+ cacheCtx.toCacheKeyObject(cacheCtx.config().getAffinityMapper().affinityKey(key));
+
+ IgniteTxKey affinityKey = cacheCtx.txKey(cacheKey);
+
+ if (!grpLockKey.equals(affinityKey))
+ throw new IgniteCheckedException("Failed to enlist key into group-lock transaction (affinity key was " +
+ "not enlisted to transaction on start) [key=" + key + ", affinityKey=" + affinityKey +
+ ", groupLockKey=" + grpLockKey + ']');
+ }
+ }
+ }
+ }
+
+ /**
+ * Performs keys locking for affinity-based group lock transactions.
+ * @return Lock future.
+ */
+ @Override public <K> IgniteInternalFuture<?> groupLockAsync(GridCacheContext cacheCtx, Collection<K> keys) {
+ assert groupLock();
+
+ try {
+ init();
+
+ GridCacheReturn ret = new GridCacheReturn(localResult(), false);
+
+ Collection<KeyCacheObject> enlisted = new ArrayList<>();
+
+ Set<KeyCacheObject> skipped = enlistWrite(
+ cacheCtx,
+ keys,
+ /** cached entry */null,
+ /** expiry - leave unchanged */null,
+ /** implicit */false,
+ /** lookup map */null,
+ /** invoke map */null,
+ /** invoke arguments */null,
+ /** retval */false,
+ /** lock only */true,
+ CU.empty0(),
+ ret,
+ enlisted,
+ null,
+ null,
+ cacheCtx.skipStore()
+ ).get();
+
+ // No keys should be skipped with empty filter.
+ assert F.isEmpty(skipped);
+
+ // Lock group key in pessimistic mode only.
+ return pessimistic() ?
+ cacheCtx.cache().txLockAsync(enlisted,
+ lockTimeout(),
+ this,
+ false,
+ false,
+ isolation,
+ isInvalidate(),
+ -1L) :
+ new GridFinishedFuture<>();
+ }
+ catch (IgniteCheckedException e) {
+ setRollbackOnly();
+
+ return new GridFinishedFuture<Object>(e);
+ }
+ }
+
+ /**
* Initializes read map.
*
* @return {@code True} if transaction was successfully started.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
index 14562ab..61041e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
@@ -58,9 +58,14 @@ public interface IgniteTxLocalEx extends IgniteInternalTx {
public void userRollback() throws IgniteCheckedException;
/**
+ * @return Group lock entry if this is a group-lock transaction.
+ */
+ @Nullable public IgniteTxEntry groupLockEntry();
+
+ /**
* @param cacheCtx Cache context.
* @param keys Keys to get.
- * @param cached Cached entry if this method is called from entry wrapper
+ * @param cached Cached entry if this method is called from entry wrapper.
* Cached entry is passed if and only if there is only one key in collection of keys.
* @param deserializePortable Deserialize portable flag.
* @param skipVals Skip values flag.
@@ -139,6 +144,20 @@ public interface IgniteTxLocalEx extends IgniteInternalTx {
Map<KeyCacheObject, GridCacheVersion> drMap);
/**
+ * Performs keys locking for affinity-based group lock transactions.
+ *
+ * @param cacheCtx Cache context.
+ * @param keys Keys to lock.
+ * @return Lock future.
+ */
+ public <K> IgniteInternalFuture<?> groupLockAsync(GridCacheContext cacheCtx, Collection<K> keys);
+
+ /**
+ * @return {@code True} if keys from the same partition are allowed to be enlisted in group-lock transaction.
+ */
+ public boolean partitionLock();
+
+ /**
* @return Return value for
*/
public GridCacheReturn implicitSingleResult();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 8e95a5d..8a1d490 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -347,6 +347,8 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
* @param isolation Isolation.
* @param timeout transaction timeout.
* @param txSize Expected transaction size.
+ * @param grpLockKey Group lock key if this is a group-lock transaction.
+ * @param partLock {@code True} if partition is locked.
* @return New transaction.
*/
public IgniteTxLocalAdapter newTx(
@@ -357,7 +359,9 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
TransactionIsolation isolation,
long timeout,
boolean storeEnabled,
- int txSize) {
+ int txSize,
+ @Nullable IgniteTxKey grpLockKey,
+ boolean partLock) {
assert sysCacheCtx == null || sysCacheCtx.systemTx();
UUID subjId = null; // TODO GG-9141 how to get subj ID?
@@ -375,6 +379,8 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
timeout,
storeEnabled,
txSize,
+ grpLockKey,
+ partLock,
subjId,
taskNameHash);
@@ -1201,10 +1207,13 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
cctx.kernalContext().dataStructures().onTxCommitted(tx);
// 4. Unlock write resources.
- unlockMultiple(tx, tx.writeEntries());
+ if (tx.groupLock())
+ unlockGroupLocks(tx);
+ else
+ unlockMultiple(tx, tx.writeEntries());
// 5. For pessimistic transaction, unlock read resources if required.
- if (tx.pessimistic() && !tx.readCommitted())
+ if (tx.pessimistic() && !tx.readCommitted() && !tx.groupLock())
unlockMultiple(tx, tx.readEntries());
// 6. Notify evictions.
@@ -1432,7 +1441,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
* @param tx Transaction to notify evictions for.
*/
private void notifyEvitions(IgniteInternalTx tx) {
- if (tx.internal())
+ if (tx.internal() && !tx.groupLock())
return;
for (IgniteTxEntry txEntry : tx.allEntries())
@@ -1608,6 +1617,51 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
}
/**
+ * Unlocks entries locked by group transaction.
+ *
+ * @param txx Transaction.
+ */
+ @SuppressWarnings("unchecked")
+ private void unlockGroupLocks(IgniteInternalTx txx) {
+ IgniteTxKey grpLockKey = txx.groupLockKey();
+
+ assert grpLockKey != null;
+
+ if (grpLockKey == null)
+ return;
+
+ IgniteTxEntry txEntry = txx.entry(grpLockKey);
+
+ assert txEntry != null || (txx.near() && !txx.local());
+
+ if (txEntry != null) {
+ GridCacheContext cacheCtx = txEntry.context();
+
+ // Group-locked entries must be locked.
+ while (true) {
+ try {
+ GridCacheEntryEx entry = txEntry.cached();
+
+ assert entry != null;
+
+ entry.txUnlock(txx);
+
+ break;
+ }
+ catch (GridCacheEntryRemovedException ignored) {
+ if (log.isDebugEnabled())
+ log.debug("Got removed entry in TM unlockGroupLocks(..) method (will retry): " + txEntry);
+
+ GridCacheAdapter cache = cacheCtx.cache();
+
+ // Renew cache entry.
+ txEntry.cached(cache.entryEx(txEntry.key()));
+ }
+ }
+ }
+ }
+
+ /**
* @param tx Owning transaction.
* @param entries Entries to unlock.
*/
@@ -1762,7 +1816,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
if (nearVer.equals(tx.nearXidVersion())) {
TransactionState state = tx.state();
- IgniteInternalFuture<?> prepFut = tx.currentPrepareFuture();
+ IgniteInternalFuture<IgniteInternalTx> prepFut = tx.currentPrepareFuture();
if (prepFut != null && !prepFut.isDone()) {
if (log.isDebugEnabled())
@@ -1774,8 +1828,8 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
final Collection<GridCacheVersion> processedVers0 = processedVers;
- prepFut.listen(new CI1<IgniteInternalFuture<?>>() {
- @Override public void apply(IgniteInternalFuture<?> prepFut) {
+ prepFut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
+ @Override public void apply(IgniteInternalFuture<IgniteInternalTx> prepFut) {
if (log.isDebugEnabled())
log.debug("Transaction prepare future finished: " + tx);
@@ -1975,11 +2029,11 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
if (tx.state() == PREPARED)
commitIfPrepared(tx);
else {
- IgniteInternalFuture<?> prepFut = tx.currentPrepareFuture();
+ IgniteInternalFuture<IgniteInternalTx> prepFut = tx.currentPrepareFuture();
if (prepFut != null) {
- prepFut.listen(new CI1<IgniteInternalFuture<?>>() {
- @Override public void apply(IgniteInternalFuture<?> fut) {
+ prepFut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
+ @Override public void apply(IgniteInternalFuture<IgniteInternalTx> fut) {
if (tx.state() == PREPARED)
commitIfPrepared(tx);
else if (tx.setRollbackOnly())
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
index fed7ebd..6b921f4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
@@ -22,7 +22,6 @@ import org.jetbrains.annotations.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
-import java.util.*;
/**
* Wrapper for data where resource should be injected.
@@ -44,7 +43,10 @@ class GridResourceField {
* @param field Field where resource should be injected.
* @param ann Resource annotation.
*/
- GridResourceField(@NotNull Field field, @NotNull Annotation ann) {
+ GridResourceField(Field field, @Nullable Annotation ann) {
+ assert field != null;
+ assert ann != null || GridResourceUtils.mayRequireResources(field);
+
this.field = field;
this.ann = ann;
@@ -76,16 +78,6 @@ class GridResourceField {
return ann == null;
}
- /**
- * @param c Closure.
- */
- public static GridResourceField[] toArray(Collection<GridResourceField> c) {
- if (c.isEmpty())
- return EMPTY_ARRAY;
-
- return c.toArray(new GridResourceField[c.size()]);
- }
-
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridResourceField.class, this);
[8/8] incubator-ignite git commit: Revert "ignite-471: fixed NPE in
PortableMarshaller"
Posted by sb...@apache.org.
Revert "ignite-471: fixed NPE in PortableMarshaller"
This reverts commit b84cef7dcebb6f949d89af2c3c424aa182b6c315, reversing
changes made to 095e3f9b924279d1220d5ad8542ea4df728eba97.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/8a6dd007
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/8a6dd007
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/8a6dd007
Branch: refs/heads/ignite-471
Commit: 8a6dd007d79e6bd62fb288f1c38310860949ca45
Parents: 477dea6
Author: dmagda <ma...@gmail.com>
Authored: Sat May 16 10:05:16 2015 +0300
Committer: dmagda <ma...@gmail.com>
Committed: Sat May 16 10:05:16 2015 +0300
----------------------------------------------------------------------
assembly/release-base.xml | 4 +-
bin/ignite-schema-import.bat | 2 +-
bin/ignite-schema-import.sh | 2 +-
bin/ignite.bat | 2 +-
bin/ignite.sh | 2 +-
bin/ignitevisorcmd.bat | 2 +-
bin/ignitevisorcmd.sh | 2 +-
bin/include/build-classpath.bat | 46 -
bin/include/build-classpath.sh | 71 --
bin/include/functions.sh | 2 +-
bin/include/target-classpath.bat | 46 +
bin/include/target-classpath.sh | 71 ++
.../streaming/StreamTransformerExample.java | 4 +-
.../streaming/StreamVisitorExample.java | 4 +-
.../ignite/examples/streaming/package-info.java | 1 +
.../streaming/wordcount/CacheConfig.java | 2 +-
.../streaming/wordcount/QueryWords.java | 12 +-
.../streaming/wordcount/StreamWords.java | 12 +-
.../streaming/wordcount/package-info.java | 1 +
.../socket/WordsSocketStreamerClient.java | 82 --
.../socket/WordsSocketStreamerServer.java | 124 ---
.../wordcount/socket/package-info.java | 21 -
.../org/apache/ignite/internal/IgnitionEx.java | 136 ++-
.../internal/direct/DirectByteBufferStream.java | 4 +-
.../internal/interop/InteropBootstrap.java | 34 -
.../interop/InteropBootstrapFactory.java | 39 -
.../internal/interop/InteropIgnition.java | 103 --
.../internal/interop/InteropProcessor.java | 25 -
.../eventstorage/GridEventStorageManager.java | 5 +-
.../processors/cache/GridCacheAdapter.java | 127 ++-
.../processors/cache/GridCacheContext.java | 7 -
.../processors/cache/GridCacheMapEntry.java | 106 +-
.../processors/cache/GridCacheMvccManager.java | 4 +-
.../GridDistributedCacheAdapter.java | 210 ++--
.../distributed/GridDistributedLockRequest.java | 111 +-
.../GridDistributedTxFinishRequest.java | 70 +-
.../GridDistributedTxPrepareRequest.java | 112 +-
.../GridDistributedTxRemoteAdapter.java | 20 +-
.../distributed/dht/GridDhtCacheAdapter.java | 16 +-
.../distributed/dht/GridDhtLockFuture.java | 2 +
.../distributed/dht/GridDhtLockRequest.java | 45 +-
.../dht/GridDhtOffHeapCacheEntry.java | 63 --
.../dht/GridDhtTransactionalCacheAdapter.java | 15 +-
.../distributed/dht/GridDhtTxFinishFuture.java | 3 +
.../distributed/dht/GridDhtTxFinishRequest.java | 43 +-
.../cache/distributed/dht/GridDhtTxLocal.java | 38 +-
.../distributed/dht/GridDhtTxLocalAdapter.java | 95 +-
.../cache/distributed/dht/GridDhtTxMapping.java | 2 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 99 +-
.../dht/GridDhtTxPrepareRequest.java | 60 +-
.../cache/distributed/dht/GridDhtTxRemote.java | 8 +-
.../distributed/dht/GridNoStorageCacheMap.java | 4 +-
.../dht/atomic/GridDhtAtomicCache.java | 3 -
.../atomic/GridDhtAtomicOffHeapCacheEntry.java | 63 --
.../dht/colocated/GridDhtColocatedCache.java | 5 +-
.../colocated/GridDhtColocatedLockFuture.java | 31 +-
.../GridDhtColocatedOffHeapCacheEntry.java | 63 --
.../colocated/GridDhtDetachedCacheEntry.java | 4 +-
.../GridDhtPartitionsExchangeFuture.java | 2 +-
.../distributed/near/GridNearCacheAdapter.java | 3 -
.../distributed/near/GridNearCacheEntry.java | 4 +-
.../distributed/near/GridNearLockFuture.java | 11 +
.../distributed/near/GridNearLockRequest.java | 61 +-
.../near/GridNearOffHeapCacheEntry.java | 60 -
.../near/GridNearOptimisticTxPrepareFuture.java | 768 -------------
.../GridNearPessimisticTxPrepareFuture.java | 347 ------
.../near/GridNearTransactionalCache.java | 4 +
.../near/GridNearTxFinishRequest.java | 28 +-
.../cache/distributed/near/GridNearTxLocal.java | 104 +-
.../near/GridNearTxPrepareFuture.java | 1050 ++++++++++++++++++
.../near/GridNearTxPrepareFutureAdapter.java | 226 ----
.../near/GridNearTxPrepareRequest.java | 52 +-
.../distributed/near/GridNearTxRemote.java | 24 +-
.../cache/local/GridLocalCacheEntry.java | 18 -
.../cache/transactions/IgniteInternalTx.java | 14 +-
.../transactions/IgniteTransactionsImpl.java | 4 +-
.../cache/transactions/IgniteTxAdapter.java | 74 +-
.../cache/transactions/IgniteTxEntry.java | 48 +-
.../cache/transactions/IgniteTxHandler.java | 74 +-
.../transactions/IgniteTxLocalAdapter.java | 167 ++-
.../cache/transactions/IgniteTxLocalEx.java | 21 +-
.../cache/transactions/IgniteTxManager.java | 74 +-
.../processors/resource/GridResourceField.java | 16 +-
.../processors/resource/GridResourceIoc.java | 389 ++++---
.../processors/resource/GridResourceMethod.java | 13 -
.../resource/GridResourceProcessor.java | 20 +-
.../ignite/internal/util/IgniteUtils.java | 22 +-
.../util/lang/GridComputeJobWrapper.java | 96 ++
.../internal/util/nio/GridBufferedParser.java | 4 +
.../internal/util/nio/GridDelimitedParser.java | 91 --
.../util/nio/GridNioDelimitedBuffer.java | 106 --
.../communication/tcp/TcpCommunicationSpi.java | 2 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 48 +-
.../discovery/tcp/TcpDiscoverySpiAdapter.java | 8 +-
.../org/apache/ignite/stream/StreamAdapter.java | 111 --
.../ignite/stream/StreamTupleExtractor.java | 33 -
.../stream/socket/SocketMessageConverter.java | 31 -
.../ignite/stream/socket/SocketStreamer.java | 218 ----
.../ignite/stream/socket/package-info.java | 21 -
.../resources/META-INF/classnames.properties | 1 +
.../cache/CacheOffheapMapEntrySelfTest.java | 168 ---
.../cache/CacheRemoveAllSelfTest.java | 81 --
.../GridCacheAbstractFailoverSelfTest.java | 8 +-
.../GridCacheAbstractNodeRestartSelfTest.java | 11 +-
.../distributed/GridCacheLockAbstractTest.java | 2 +
.../distributed/IgniteTxGetAfterStopTest.java | 131 ---
...achePartitionedNearDisabledLockSelfTest.java | 47 -
...ePrimaryNodeFailureRecoveryAbstractTest.java | 4 +-
...idCacheAtomicReplicatedFailoverSelfTest.java | 6 -
.../GridCachePartitionedTxSalvageSelfTest.java | 25 +-
.../near/NoneRebalanceModeSelfTest.java | 67 --
.../GridCacheReplicatedFailoverSelfTest.java | 6 -
.../GridCacheReplicatedLockSelfTest.java | 5 -
.../GridCacheReplicatedNodeRestartSelfTest.java | 80 --
.../GridCacheLocalIsolatedNodesSelfTest.java | 18 +-
.../util/nio/GridNioDelimitedBufferTest.java | 112 --
.../discovery/tcp/TcpDiscoveryRestartTest.java | 199 ----
.../stream/socket/SocketStreamerSelfTest.java | 316 ------
.../ignite/stream/socket/package-info.java | 21 -
.../IgniteCacheFailoverTestSuite.java | 10 +-
.../testsuites/IgniteCacheRestartTestSuite.java | 8 +-
.../testsuites/IgniteCacheTestSuite2.java | 2 -
.../testsuites/IgniteCacheTestSuite3.java | 2 -
.../testsuites/IgniteCacheTestSuite4.java | 4 -
.../testsuites/IgniteStreamTestSuite.java | 39 -
.../testsuites/IgniteUtilSelfTestSuite.java | 1 -
.../cache/GridCacheOffheapIndexGetSelfTest.java | 111 --
.../IgniteCacheWithIndexingTestSuite.java | 2 -
.../processors/cache/jta/CacheJtaManager.java | 4 +-
.../scalar/tests/ScalarCacheQueriesSpec.scala | 154 +--
.../ignite/scalar/tests/ScalarCacheSpec.scala | 23 +-
.../scalar/tests/ScalarConversionsSpec.scala | 43 +-
.../scalar/tests/ScalarProjectionSpec.scala | 128 +--
.../scalar/tests/ScalarReturnableSpec.scala | 41 +-
modules/visor-console/pom.xml | 2 +-
.../ignite/visor/VisorRuntimeBaseSpec.scala | 2 +-
.../visor/commands/VisorArgListSpec.scala | 60 +-
.../commands/VisorFileNameCompleterSpec.scala | 34 +-
.../commands/ack/VisorAckCommandSpec.scala | 20 +-
.../commands/alert/VisorAlertCommandSpec.scala | 68 +-
.../cache/VisorCacheClearCommandSpec.scala | 48 +-
.../commands/cache/VisorCacheCommandSpec.scala | 66 +-
.../config/VisorConfigurationCommandSpec.scala | 8 +-
.../cswap/VisorCacheSwapCommandSpec.scala | 24 +-
.../deploy/VisorDeployCommandSpec.scala | 10 +-
.../disco/VisorDiscoveryCommandSpec.scala | 46 +-
.../events/VisorEventsCommandSpec.scala | 28 +-
.../visor/commands/gc/VisorGcCommandSpec.scala | 30 +-
.../commands/help/VisorHelpCommandSpec.scala | 57 +-
.../commands/kill/VisorKillCommandSpec.scala | 58 +-
.../commands/log/VisorLogCommandSpec.scala | 10 +-
.../commands/mem/VisorMemoryCommandSpec.scala | 77 +-
.../commands/node/VisorNodeCommandSpec.scala | 22 +-
.../commands/open/VisorOpenCommandSpec.scala | 16 +-
.../commands/ping/VisorPingCommandSpec.scala | 16 +-
.../commands/start/VisorStartCommandSpec.scala | 126 +--
.../commands/tasks/VisorTasksCommandSpec.scala | 112 +-
.../commands/top/VisorTopologyCommandSpec.scala | 52 +-
.../commands/vvm/VisorVvmCommandSpec.scala | 30 +-
parent/pom.xml | 2 -
pom.xml | 85 +-
161 files changed, 3836 insertions(+), 5910 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/assembly/release-base.xml
----------------------------------------------------------------------
diff --git a/assembly/release-base.xml b/assembly/release-base.xml
index 88f1d10..6d6465e 100644
--- a/assembly/release-base.xml
+++ b/assembly/release-base.xml
@@ -71,7 +71,7 @@
<excludes>
<exclude>**/*hadoop*.bat</exclude>
<exclude>igniterouter.bat</exclude>
- <exclude>**/build-classpath.bat</exclude>
+ <exclude>**/target-classpath.bat</exclude>
<exclude>ignitevisorcmd.bat</exclude>
<exclude>ignite-schema-import.bat</exclude>
</excludes>
@@ -87,7 +87,7 @@
<excludes>
<exclude>**/*hadoop*.sh</exclude>
<exclude>igniterouter.sh</exclude>
- <exclude>**/build-classpath.sh</exclude>
+ <exclude>**/target-classpath.sh</exclude>
<exclude>**/service.sh</exclude>
<exclude>ignitevisorcmd.sh</exclude>
<exclude>ignite-schema-import.sh</exclude>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/bin/ignite-schema-import.bat
----------------------------------------------------------------------
diff --git a/bin/ignite-schema-import.bat b/bin/ignite-schema-import.bat
index a4ec86b..4731105 100644
--- a/bin/ignite-schema-import.bat
+++ b/bin/ignite-schema-import.bat
@@ -91,7 +91,7 @@ if /i "%SCRIPTS_HOME%\" == "%~dp0" goto run
:: Set IGNITE_LIBS
::
call "%SCRIPTS_HOME%\include\setenv.bat"
-call "%SCRIPTS_HOME%\include\build-classpath.bat" &:: Will be removed in the binary release.
+call "%SCRIPTS_HOME%\include\target-classpath.bat" &:: Will be removed in release.
set CP=%JAVA_HOME%\jre\lib\jfxrt.jar;%IGNITE_HOME%\bin\include\schema-import\*;%IGNITE_LIBS%
::
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/bin/ignite-schema-import.sh
----------------------------------------------------------------------
diff --git a/bin/ignite-schema-import.sh b/bin/ignite-schema-import.sh
index 1029882..0a70d54 100755
--- a/bin/ignite-schema-import.sh
+++ b/bin/ignite-schema-import.sh
@@ -57,7 +57,7 @@ setIgniteHome
# Set IGNITE_LIBS.
#
. "${SCRIPTS_HOME}"/include/setenv.sh
-. "${SCRIPTS_HOME}"/include/build-classpath.sh # Will be removed in the binary release.
+. "${SCRIPTS_HOME}"/include/target-classpath.sh # Will be removed in release.
CP="${JAVA_HOME}/jre/lib/jfxrt.jar${SEP}${IGNITE_HOME}/bin/include/schema-import/*${SEP}${IGNITE_LIBS}"
#
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/bin/ignite.bat
----------------------------------------------------------------------
diff --git a/bin/ignite.bat b/bin/ignite.bat
index 1a4a58c..687db60 100644
--- a/bin/ignite.bat
+++ b/bin/ignite.bat
@@ -102,7 +102,7 @@ if "%OS%" == "Windows_NT" set PROG_NAME=%~nx0%
:: Set IGNITE_LIBS
::
call "%SCRIPTS_HOME%\include\setenv.bat"
-call "%SCRIPTS_HOME%\include\build-classpath.bat" &:: Will be removed in the binary release.
+call "%SCRIPTS_HOME%\include\target-classpath.bat" &:: Will be removed in release.
set CP=%IGNITE_LIBS%
::
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/bin/ignite.sh
----------------------------------------------------------------------
diff --git a/bin/ignite.sh b/bin/ignite.sh
index 660a80f..a246613 100755
--- a/bin/ignite.sh
+++ b/bin/ignite.sh
@@ -58,7 +58,7 @@ fi
# Set IGNITE_LIBS.
#
. "${SCRIPTS_HOME}"/include/setenv.sh
-. "${SCRIPTS_HOME}"/include/build-classpath.sh # Will be removed in the binary release.
+. "${SCRIPTS_HOME}"/include/target-classpath.sh # Will be removed in release.
CP="${IGNITE_LIBS}"
RANDOM_NUMBER=$("$JAVA" -cp "${CP}" org.apache.ignite.startup.cmdline.CommandLineRandomNumberGenerator)
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/bin/ignitevisorcmd.bat
----------------------------------------------------------------------
diff --git a/bin/ignitevisorcmd.bat b/bin/ignitevisorcmd.bat
index 4a1aafd..1cf2b26 100644
--- a/bin/ignitevisorcmd.bat
+++ b/bin/ignitevisorcmd.bat
@@ -100,7 +100,7 @@ if "%OS%" == "Windows_NT" set PROG_NAME=%~nx0%
:: Set IGNITE_LIBS
::
call "%SCRIPTS_HOME%\include\setenv.bat"
-call "%SCRIPTS_HOME%\include\build-classpath.bat" &:: Will be removed in the binary release.
+call "%SCRIPTS_HOME%\include\target-classpath.bat" &:: Will be removed in release.
set CP=%IGNITE_HOME%\bin\include\visor-common\*;%IGNITE_HOME%\bin\include\visorcmd\*;%IGNITE_LIBS%
::
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/bin/ignitevisorcmd.sh
----------------------------------------------------------------------
diff --git a/bin/ignitevisorcmd.sh b/bin/ignitevisorcmd.sh
index fe74f6a..6118560 100755
--- a/bin/ignitevisorcmd.sh
+++ b/bin/ignitevisorcmd.sh
@@ -53,7 +53,7 @@ setIgniteHome
# Set IGNITE_LIBS.
#
. "${SCRIPTS_HOME}"/include/setenv.sh
-. "${SCRIPTS_HOME}"/include/build-classpath.sh # Will be removed in the binary release.
+. "${SCRIPTS_HOME}"/include/target-classpath.sh # Will be removed in release.
CP="${IGNITE_HOME}/bin/include/visor-common/*${SEP}${IGNITE_HOME}/bin/include/visorcmd/*${SEP}${IGNITE_LIBS}"
#
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/bin/include/build-classpath.bat
----------------------------------------------------------------------
diff --git a/bin/include/build-classpath.bat b/bin/include/build-classpath.bat
deleted file mode 100644
index 5f932d3..0000000
--- a/bin/include/build-classpath.bat
+++ /dev/null
@@ -1,46 +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.
-::
-
-:: Target class path resolver.
-::
-:: Can be used like:
-:: call "%IGNITE_HOME%\bin\include\build-classpath.bat"
-:: in other scripts to set classpath using libs from target folder.
-::
-:: Will be excluded in release.
-
-@echo off
-
-for /D %%F in (modules\*) do if not %%F == "modules" call :includeToClassPath %%F
-
-for /D %%F in (%IGNITE_HOME%\modules\*) do if not %%F == "%IGNITE_HOME%\modules" call :includeToClassPath %%F
-
-goto :eof
-
-:includeToClassPath
-if exist "%1\target\" (
- if exist "%1\target\classes\" call :concat %1\target\classes
-
- if exist "%1\target\test-classes\" call :concat %1\target\test-classes
-
- if exist "%1\target\libs\" call :concat %1\target\libs\*
-)
-goto :eof
-
-:concat
-set IGNITE_LIBS=%IGNITE_LIBS%;%1
-goto :eof
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/bin/include/build-classpath.sh
----------------------------------------------------------------------
diff --git a/bin/include/build-classpath.sh b/bin/include/build-classpath.sh
deleted file mode 100644
index 9f0c878..0000000
--- a/bin/include/build-classpath.sh
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/sh
-#
-# 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.
-#
-
-# Target class path resolver.
-#
-# Can be used like:
-# . "${IGNITE_HOME}"/bin/include/build-classpath.sh
-# in other scripts to set classpath using libs from target folder.
-#
-# Will be excluded in release.
-
-
-#
-# OS specific support.
-#
-SEP=":";
-
-case "`uname`" in
- MINGW*)
- SEP=";";
- export IGNITE_HOME=`echo $IGNITE_HOME | sed -e 's/^\/\([a-zA-Z]\)/\1:/'`
- ;;
- CYGWIN*)
- SEP=";";
- export IGNITE_HOME=`echo $IGNITE_HOME | sed -e 's/^\/\([a-zA-Z]\)/\1:/'`
- ;;
-esac
-
-includeToClassPath() {
- for file in $1/*
- do
- if [ -d ${file} ] && [ -d "${file}/target" ]; then
- if [ -d "${file}/target/classes" ]; then
- IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/classes
- fi
-
- if [ -d "${file}/target/test-classes" ]; then
- IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/test-classes
- fi
-
- if [ -d "${file}/target/libs" ]; then
- IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/libs/*
- fi
- fi
- done
-}
-
-#
-# Include target libraries for enterprise modules to classpath.
-#
-includeToClassPath modules
-
-#
-# Include target libraries for opensourse modules to classpath.
-#
-includeToClassPath ${IGNITE_HOME}/modules
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/bin/include/functions.sh
----------------------------------------------------------------------
diff --git a/bin/include/functions.sh b/bin/include/functions.sh
index b18b150..f0430c1 100755
--- a/bin/include/functions.sh
+++ b/bin/include/functions.sh
@@ -34,7 +34,7 @@
checkJava() {
# Check JAVA_HOME.
if [ "$JAVA_HOME" = "" ]; then
- JAVA=`type -p java`
+ JAVA=`which java`
RETCODE=$?
if [ $RETCODE -ne 0 ]; then
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/bin/include/target-classpath.bat
----------------------------------------------------------------------
diff --git a/bin/include/target-classpath.bat b/bin/include/target-classpath.bat
new file mode 100644
index 0000000..4416557
--- /dev/null
+++ b/bin/include/target-classpath.bat
@@ -0,0 +1,46 @@
+::
+:: 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.
+::
+
+:: Target class path resolver.
+::
+:: Can be used like:
+:: call "%IGNITE_HOME%\bin\include\target-classpath.bat"
+:: in other scripts to set classpath using libs from target folder.
+::
+:: Will be excluded in release.
+
+@echo off
+
+for /D %%F in (modules\*) do if not %%F == "modules" call :includeToClassPath %%F
+
+for /D %%F in (%IGNITE_HOME%\modules\*) do if not %%F == "%IGNITE_HOME%\modules" call :includeToClassPath %%F
+
+goto :eof
+
+:includeToClassPath
+if exist "%1\target\" (
+ if exist "%1\target\classes\" call :concat %1\target\classes
+
+ if exist "%1\target\test-classes\" call :concat %1\target\test-classes
+
+ if exist "%1\target\libs\" call :concat %1\target\libs\*
+)
+goto :eof
+
+:concat
+set IGNITE_LIBS=%IGNITE_LIBS%;%1
+goto :eof
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/bin/include/target-classpath.sh
----------------------------------------------------------------------
diff --git a/bin/include/target-classpath.sh b/bin/include/target-classpath.sh
new file mode 100644
index 0000000..871d517
--- /dev/null
+++ b/bin/include/target-classpath.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+#
+# 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.
+#
+
+# Target class path resolver.
+#
+# Can be used like:
+# . "${IGNITE_HOME}"/bin/include/target-classpath.sh
+# in other scripts to set classpath using libs from target folder.
+#
+# Will be excluded in release.
+
+
+#
+# OS specific support.
+#
+SEP=":";
+
+case "`uname`" in
+ MINGW*)
+ SEP=";";
+ export IGNITE_HOME=`echo $IGNITE_HOME | sed -e 's/^\/\([a-zA-Z]\)/\1:/'`
+ ;;
+ CYGWIN*)
+ SEP=";";
+ export IGNITE_HOME=`echo $IGNITE_HOME | sed -e 's/^\/\([a-zA-Z]\)/\1:/'`
+ ;;
+esac
+
+includeToClassPath() {
+ for file in $1/*
+ do
+ if [ -d ${file} ] && [ -d "${file}/target" ]; then
+ if [ -d "${file}/target/classes" ]; then
+ IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/classes
+ fi
+
+ if [ -d "${file}/target/test-classes" ]; then
+ IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/test-classes
+ fi
+
+ if [ -d "${file}/target/libs" ]; then
+ IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/libs/*
+ fi
+ fi
+ done
+}
+
+#
+# Include target libraries for enterprise modules to classpath.
+#
+includeToClassPath modules
+
+#
+# Include target libraries for opensourse modules to classpath.
+#
+includeToClassPath ${IGNITE_HOME}/modules
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java
index 966fce2..5e95892 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamTransformerExample.java
@@ -30,9 +30,11 @@ import java.util.*;
* Stream random numbers into the streaming cache.
* To start the example, you should:
* <ul>
- * <li>Start a few nodes using {@link ExampleNodeStartup}.</li>
+ * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
* <li>Start streaming using {@link StreamTransformerExample}.</li>
* </ul>
+ * <p>
+ * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
*/
public class StreamTransformerExample {
/** Random number generator. */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java
index baae5af..0fbce68 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/StreamVisitorExample.java
@@ -31,9 +31,11 @@ import java.util.*;
* Stream random numbers into the streaming cache.
* To start the example, you should:
* <ul>
- * <li>Start a few nodes using {@link ExampleNodeStartup}.</li>
+ * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
* <li>Start streaming using {@link StreamVisitorExample}.</li>
* </ul>
+ * <p>
+ * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
*/
public class StreamVisitorExample {
/** Random number generator. */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java b/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java
index 43fbab3..43dea13 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/package-info.java
@@ -16,6 +16,7 @@
*/
/**
+ * <!-- Package description. -->
* Demonstrates usage of data streamer.
*/
package org.apache.ignite.examples.streaming;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/CacheConfig.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/CacheConfig.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/CacheConfig.java
index d17b97d..58704ca 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/CacheConfig.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/CacheConfig.java
@@ -26,7 +26,7 @@ import javax.cache.expiry.*;
import static java.util.concurrent.TimeUnit.*;
/**
- * Configuration for the streaming cache to store the stream of words.
+ * Configuration for the streaming cache to store the stream of random numbers.
* This cache is configured with sliding window of 1 second, which means that
* data older than 1 second will be automatically removed from the cache.
*/
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
index 58c6ef2..3bd9d3d 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
@@ -28,18 +28,14 @@ import java.util.*;
* Periodically query popular numbers from the streaming cache.
* To start the example, you should:
* <ul>
- * <li>Start a few nodes using {@link ExampleNodeStartup}.</li>
+ * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
* <li>Start streaming using {@link StreamWords}.</li>
- * <li>Start querying popular words using {@link QueryWords}.</li>
+ * <li>Start querying popular numbers using {@link QueryWords}.</li>
* </ul>
+ * <p>
+ * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
*/
public class QueryWords {
- /**
- * Schedules words query execution.
- *
- * @param args Command line arguments (none required).
- * @throws Exception If failed.
- */
public static void main(String[] args) throws Exception {
// Mark this cluster member as client.
Ignition.setClientMode(true);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java
index 6024c4b..c59fa51 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/StreamWords.java
@@ -27,18 +27,14 @@ import java.io.*;
* Stream words into Ignite cache.
* To start the example, you should:
* <ul>
- * <li>Start a few nodes using {@link ExampleNodeStartup}.</li>
+ * <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
* <li>Start streaming using {@link StreamWords}.</li>
- * <li>Start querying popular words using {@link QueryWords}.</li>
+ * <li>Start querying popular numbers using {@link QueryWords}.</li>
* </ul>
+ * <p>
+ * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
*/
public class StreamWords {
- /**
- * Starts words streaming.
- *
- * @param args Command line arguments (none required).
- * @throws Exception If failed.
- */
public static void main(String[] args) throws Exception {
// Mark this cluster member as client.
Ignition.setClientMode(true);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/package-info.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/package-info.java
index 5d48ae3..010f86a 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/package-info.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/package-info.java
@@ -16,6 +16,7 @@
*/
/**
+ * <!-- Package description. -->
* Streaming word count example.
*/
package org.apache.ignite.examples.streaming.wordcount;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerClient.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerClient.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerClient.java
deleted file mode 100644
index c4d7b8c..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerClient.java
+++ /dev/null
@@ -1,82 +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.streaming.wordcount.socket;
-
-import org.apache.ignite.examples.*;
-import org.apache.ignite.examples.streaming.wordcount.*;
-import org.apache.ignite.stream.socket.*;
-
-import java.io.*;
-import java.net.*;
-
-/**
- * Example demonstrates streaming of data from external components into Ignite cache.
- * <p>
- * {@code WordsSocketStreamerClient} is simple socket streaming client implementation that sends words to socket server
- * based on {@link SocketStreamer} using message delimiter based protocol. Example illustrates usage of TCP socket
- * streamer in case of non-Java clients. In this example words are zero-terminated strings.
- * <p>
- * To start the example, you should:
- * <ul>
- * <li>Start a few nodes using {@link ExampleNodeStartup}.</li>
- * <li>Start socket server using {@link WordsSocketStreamerServer}.</li>
- * <li>Start a few socket clients using {@link WordsSocketStreamerClient}.</li>
- * <li>Start querying popular words using {@link QueryWords}.</li>
- * </ul>
- */
-public class WordsSocketStreamerClient {
- /** Port. */
- private static final int PORT = 5555;
-
- /** Delimiter. */
- private static final byte[] DELIM = new byte[] {0};
-
- /**
- * @param args Args.
- */
- public static void main(String[] args) throws IOException {
- InetAddress addr = InetAddress.getLocalHost();
-
- try (
- Socket sock = new Socket(addr, PORT);
- OutputStream oos = new BufferedOutputStream(sock.getOutputStream())
- ) {
- System.out.println("Words streaming started.");
-
- while (true) {
- try (InputStream in = WordsSocketStreamerClient.class.getResourceAsStream("../alice-in-wonderland.txt");
- LineNumberReader rdr = new LineNumberReader(new InputStreamReader(in))) {
- for (String line = rdr.readLine(); line != null; line = rdr.readLine()) {
- for (String word : line.split(" ")) {
- if (!word.isEmpty()) {
- // Stream words into Ignite through socket.
- byte[] arr = word.getBytes("ASCII");
-
- // Write message
- oos.write(arr);
-
- // Write message delimiter
- oos.write(DELIM);
- }
- }
- }
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
deleted file mode 100644
index 9e68096..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/WordsSocketStreamerServer.java
+++ /dev/null
@@ -1,124 +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.streaming.wordcount.socket;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.affinity.*;
-import org.apache.ignite.examples.*;
-import org.apache.ignite.examples.streaming.wordcount.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.stream.*;
-import org.apache.ignite.stream.socket.*;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-/**
- * Example demonstrates streaming of data from external components into Ignite cache.
- * <p>
- * {@code WordsSocketStreamerServer} is simple socket streaming server implementation that
- * receives words from socket using {@link SocketStreamer} and message delimiter based protocol
- * and streams them into Ignite cache. Example illustrates usage of TCP socket streamer in case of non-Java clients.
- * In this example words are zero-terminated strings.
- * <p>
- * To start the example, you should:
- * <ul>
- * <li>Start a few nodes using {@link ExampleNodeStartup}.</li>
- * <li>Start socket server using {@link WordsSocketStreamerServer}.</li>
- * <li>Start a few socket clients using {@link WordsSocketStreamerClient}.</li>
- * <li>Start querying popular words using {@link QueryWords}.</li>
- * </ul>
- */
-public class WordsSocketStreamerServer {
- /** Port. */
- private static final int PORT = 5555;
-
- /** Delimiter. */
- private static final byte[] DELIM = new byte[] {0};
-
- /**
- * Starts socket streaming server.
- *
- * @param args Command line arguments (none required).
- * @throws Exception If failed.
- */
- public static void main(String[] args) throws Exception {
- // Mark this cluster member as client.
- Ignition.setClientMode(true);
-
- Ignite ignite = Ignition.start("examples/config/example-ignite.xml");
-
- if (!ExamplesUtils.hasServerNodes(ignite)) {
- ignite.close();
-
- return;
- }
-
- // The cache is configured with sliding window holding 1 second of the streaming data.
- IgniteCache<AffinityUuid, String> stmCache = ignite.getOrCreateCache(CacheConfig.wordCache());
-
- IgniteDataStreamer<AffinityUuid, String> stmr = ignite.dataStreamer(stmCache.getName());
-
- InetAddress addr = InetAddress.getLocalHost();
-
- // Configure socket streamer
- SocketStreamer<String, AffinityUuid, String> sockStmr = new SocketStreamer<>();
-
- sockStmr.setAddr(addr);
-
- sockStmr.setPort(PORT);
-
- sockStmr.setDelimiter(DELIM);
-
- sockStmr.setIgnite(ignite);
-
- sockStmr.setStreamer(stmr);
-
- // Converter from zero-terminated string to Java strings.
- sockStmr.setConverter(new SocketMessageConverter<String>() {
- @Override public String convert(byte[] msg) {
- try {
- return new String(msg, "ASCII");
- }
- catch (UnsupportedEncodingException e) {
- throw new IgniteException(e);
- }
- }
- });
-
- sockStmr.setTupleExtractor(new StreamTupleExtractor<String, AffinityUuid, String>() {
- @Override public Map.Entry<AffinityUuid, String> extract(String word) {
- // By using AffinityUuid we ensure that identical
- // words are processed on the same cluster node.
- return new IgniteBiTuple<>(new AffinityUuid(word), word);
- }
- });
-
- try {
- sockStmr.start();
- }
- catch (IgniteException e) {
- System.err.println("Streaming server didn't start due to an error: ");
-
- e.printStackTrace();
-
- ignite.close();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/package-info.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/package-info.java
deleted file mode 100644
index 048299f..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/socket/package-info.java
+++ /dev/null
@@ -1,21 +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.
- */
-
-/**
- * Contains {@link org.apache.ignite.stream.socket.SocketStreamer} usage examples.
- */
-package org.apache.ignite.examples.streaming.wordcount.socket;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index d54e06f..8d88677 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -532,6 +532,22 @@ public class IgnitionEx {
}
/**
+ * Start Grid passing a closure which will modify configuration before it is passed to start routine.
+ *
+ * @param springCfgPath Spring config path.
+ * @param gridName Grid name.
+ * @param cfgClo Configuration closure.
+ * @return Started Grid.
+ * @throws IgniteCheckedException If failed.
+ */
+ public static Ignite startWithClosure(@Nullable String springCfgPath, @Nullable String gridName,
+ IgniteClosure<IgniteConfiguration, IgniteConfiguration> cfgClo) throws IgniteCheckedException {
+ URL url = U.resolveSpringUrl(springCfgPath);
+
+ return start(url, gridName, null, cfgClo);
+ }
+
+ /**
* Loads all grid configurations specified within given Spring XML configuration file.
* <p>
* Usually Spring XML configuration file will contain only one Grid definition. Note that
@@ -718,40 +734,7 @@ public class IgnitionEx {
*/
public static Ignite start(URL springCfgUrl, @Nullable String gridName,
@Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException {
- A.notNull(springCfgUrl, "springCfgUrl");
-
- boolean isLog4jUsed = U.gridClassLoader().getResource("org/apache/log4j/Appender.class") != null;
-
- IgniteBiTuple<Object, Object> t = null;
-
- if (isLog4jUsed) {
- try {
- t = U.addLog4jNoOpLogger();
- }
- catch (IgniteCheckedException ignore) {
- isLog4jUsed = false;
- }
- }
-
- Collection<Handler> savedHnds = null;
-
- if (!isLog4jUsed)
- savedHnds = U.addJavaNoOpLogger();
-
- IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap;
-
- try {
- cfgMap = loadConfigurations(springCfgUrl);
- }
- finally {
- if (isLog4jUsed && t != null)
- U.removeLog4jNoOpLogger(t);
-
- if (!isLog4jUsed)
- U.removeJavaNoOpLogger(savedHnds);
- }
-
- return startConfigurations(cfgMap, springCfgUrl, gridName, springCtx);
+ return start(springCfgUrl, gridName, springCtx, null);
}
/**
@@ -797,6 +780,73 @@ public class IgnitionEx {
*/
public static Ignite start(InputStream springCfgStream, @Nullable String gridName,
@Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException {
+ return start(springCfgStream, gridName, springCtx, null);
+ }
+
+ /**
+ * Internal Spring-based start routine.
+ *
+ * @param springCfgUrl Spring XML configuration file URL. This cannot be {@code null}.
+ * @param gridName Grid name that will override default.
+ * @param springCtx Optional Spring application context.
+ * @param cfgClo Optional closure to change configuration before it is used to start the grid.
+ * @return Started grid.
+ * @throws IgniteCheckedException If failed.
+ */
+ private static Ignite start(final URL springCfgUrl, @Nullable String gridName,
+ @Nullable GridSpringResourceContext springCtx,
+ @Nullable IgniteClosure<IgniteConfiguration, IgniteConfiguration> cfgClo)
+ throws IgniteCheckedException {
+ A.notNull(springCfgUrl, "springCfgUrl");
+
+ boolean isLog4jUsed = U.gridClassLoader().getResource("org/apache/log4j/Appender.class") != null;
+
+ IgniteBiTuple<Object, Object> t = null;
+
+ if (isLog4jUsed) {
+ try {
+ t = U.addLog4jNoOpLogger();
+ }
+ catch (IgniteCheckedException ignore) {
+ isLog4jUsed = false;
+ }
+ }
+
+ Collection<Handler> savedHnds = null;
+
+ if (!isLog4jUsed)
+ savedHnds = U.addJavaNoOpLogger();
+
+ IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap;
+
+ try {
+ cfgMap = loadConfigurations(springCfgUrl);
+ }
+ finally {
+ if (isLog4jUsed && t != null)
+ U.removeLog4jNoOpLogger(t);
+
+ if (!isLog4jUsed)
+ U.removeJavaNoOpLogger(savedHnds);
+ }
+
+ return startConfigurations(cfgMap, springCfgUrl, gridName, springCtx, cfgClo);
+ }
+
+ /**
+ * Internal Spring-based start routine.
+ *
+ * @param springCfgStream Input stream containing Spring XML configuration. This cannot be {@code null}.
+ * @param gridName Grid name that will override default.
+ * @param springCtx Optional Spring application context.
+ * @param cfgClo Optional closure to change configuration before it is used to start the grid.
+ * @return Started grid.
+ * @throws IgniteCheckedException If failed.
+ */
+ private static Ignite start(final InputStream springCfgStream, @Nullable String gridName,
+ @Nullable GridSpringResourceContext springCtx,
+ @Nullable IgniteClosure<IgniteConfiguration, IgniteConfiguration> cfgClo)
+ throws IgniteCheckedException {
A.notNull(springCfgStream, "springCfgUrl");
boolean isLog4jUsed = U.gridClassLoader().getResource("org/apache/log4j/Appender.class") != null;
@@ -830,7 +880,7 @@ public class IgnitionEx {
U.removeJavaNoOpLogger(savedHnds);
}
- return startConfigurations(cfgMap, null, gridName, springCtx);
+ return startConfigurations(cfgMap, null, gridName, springCtx, cfgClo);
}
/**
@@ -840,6 +890,7 @@ public class IgnitionEx {
* @param springCfgUrl Spring XML configuration file URL.
* @param gridName Grid name that will override default.
* @param springCtx Optional Spring application context.
+ * @param cfgClo Optional closure to change configuration before it is used to start the grid.
* @return Started grid.
* @throws IgniteCheckedException If failed.
*/
@@ -847,7 +898,8 @@ public class IgnitionEx {
IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap,
URL springCfgUrl,
@Nullable String gridName,
- @Nullable GridSpringResourceContext springCtx)
+ @Nullable GridSpringResourceContext springCtx,
+ @Nullable IgniteClosure<IgniteConfiguration, IgniteConfiguration> cfgClo)
throws IgniteCheckedException {
List<IgniteNamedInstance> grids = new ArrayList<>(cfgMap.size());
@@ -858,6 +910,12 @@ public class IgnitionEx {
if (cfg.getGridName() == null && !F.isEmpty(gridName))
cfg.setGridName(gridName);
+ if (cfgClo != null) {
+ cfg = cfgClo.apply(cfg);
+
+ assert cfg != null;
+ }
+
// Use either user defined context or our one.
IgniteNamedInstance grid = start0(
new GridStartContext(cfg, springCfgUrl, springCtx == null ? cfgMap.get2() : springCtx));
@@ -1542,9 +1600,9 @@ public class IgnitionEx {
igfsExecSvc, restExecSvc,
new CA() {
@Override public void apply() {
- startLatch.countDown();
- }
- });
+ startLatch.countDown();
+ }
+ });
state = STARTED;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java
index 4ca318e..64c895b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java
@@ -66,10 +66,10 @@ public class DirectByteBufferStream {
private static final short[] SHORT_ARR_EMPTY = new short[0];
/** */
- private static final int[] INT_ARR_EMPTY = U.EMPTY_INTS;
+ private static final int[] INT_ARR_EMPTY = new int[0];
/** */
- private static final long[] LONG_ARR_EMPTY = U.EMPTY_LONGS;
+ private static final long[] LONG_ARR_EMPTY = new long[0];
/** */
private static final float[] FLOAT_ARR_EMPTY = new float[0];
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java
deleted file mode 100644
index 820bef9..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java
+++ /dev/null
@@ -1,34 +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.internal.interop;
-
-import org.apache.ignite.configuration.*;
-
-/**
- * Interop bootstrap. Responsible for starting Ignite node in interop mode.
- */
-public interface InteropBootstrap {
- /**
- * Start Ignite node.
- *
- * @param cfg Configuration.
- * @param envPtr Environment pointer.
- * @return Ignite node.
- */
- public InteropProcessor start(IgniteConfiguration cfg, long envPtr);
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrapFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrapFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrapFactory.java
deleted file mode 100644
index b61ca89..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrapFactory.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.internal.interop;
-
-import java.io.*;
-
-/**
- * Interop bootstrap factory.
- */
-public interface InteropBootstrapFactory extends Serializable {
- /**
- * Get bootstrap factory ID.
- *
- * @return ID.
- */
- public int id();
-
- /**
- * Create bootstrap instance.
- *
- * @return Bootstrap instance.
- */
- public InteropBootstrap create();
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
deleted file mode 100644
index f245122..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
+++ /dev/null
@@ -1,103 +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.internal.interop;
-
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.resource.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
-import org.jetbrains.annotations.*;
-
-import java.net.*;
-import java.security.*;
-import java.util.*;
-
-/**
- * Entry point for interop nodes.
- */
-@SuppressWarnings("UnusedDeclaration")
-public class InteropIgnition {
- /**
- * Start Ignite node in interop mode.
- *
- * @param springCfgPath Spring configuration path.
- * @param gridName Grid name.
- * @param factoryId Factory ID.
- * @param envPtr Environment pointer.
- * @return Ignite instance.
- */
- public static InteropProcessor start(@Nullable String springCfgPath, @Nullable String gridName, int factoryId,
- long envPtr) {
- IgniteConfiguration cfg = configuration(springCfgPath);
-
- if (gridName != null)
- cfg.setGridName(gridName);
-
- InteropBootstrap bootstrap = bootstrap(factoryId);
-
- return bootstrap.start(cfg, envPtr);
- }
-
- private static IgniteConfiguration configuration(@Nullable String springCfgPath) {
- try {
- URL url = springCfgPath == null ? U.resolveIgniteUrl(IgnitionEx.DFLT_CFG) :
- U.resolveSpringUrl(springCfgPath);
-
- IgniteBiTuple<IgniteConfiguration, GridSpringResourceContext> t = IgnitionEx.loadConfiguration(url);
-
- return t.get1();
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to instantiate configuration from Spring XML: " + springCfgPath, e);
- }
- }
-
- /**
- * Create bootstrap for the given factory ID.
- *
- * @param factoryId Factory ID.
- * @return Bootstrap.
- */
- private static InteropBootstrap bootstrap(final int factoryId) {
- InteropBootstrapFactory factory = AccessController.doPrivileged(
- new PrivilegedAction<InteropBootstrapFactory>() {
- @Override public InteropBootstrapFactory run() {
- for (InteropBootstrapFactory factory : ServiceLoader.load(InteropBootstrapFactory.class)) {
- if (factory.id() == factoryId)
- return factory;
- }
-
- return null;
- }
- });
-
- if (factory == null)
- throw new IgniteException("Interop factory is not found (did you put into the classpath?): " + factoryId);
-
- return factory.create();
- }
-
- /**
- * Private constructor.
- */
- private InteropIgnition() {
- // No-op.
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java
deleted file mode 100644
index 6c55296..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java
+++ /dev/null
@@ -1,25 +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.internal.interop;
-
-/**
- * Interop processor.
- */
-public interface InteropProcessor {
- // No-op.
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
index 010aab4..4b969d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java
@@ -51,6 +51,9 @@ import static org.apache.ignite.internal.managers.communication.GridIoPolicy.*;
* Grid event storage SPI manager.
*/
public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi> {
+ /** */
+ private static final int[] EMPTY = new int[0];
+
/** Local event listeners. */
private final ConcurrentMap<Integer, Set<GridLocalEventListener>> lsnrs = new ConcurrentHashMap8<>();
@@ -104,7 +107,7 @@ public class GridEventStorageManager extends GridManagerAdapter<EventStorageSpi>
int[] cfgInclEvtTypes0 = ctx.config().getIncludeEventTypes();
if (F.isEmpty(cfgInclEvtTypes0))
- cfgInclEvtTypes = U.EMPTY_INTS;
+ cfgInclEvtTypes = EMPTY;
else {
cfgInclEvtTypes0 = copy(cfgInclEvtTypes0);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index b972da8..dc13d17 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -1133,8 +1133,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
- ctx.kernalContext().task().execute(
- new ClearTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys), null).get();
+ ctx.kernalContext().task().execute(new ClearTask(ctx, keys), null).get();
}
}
@@ -1153,8 +1152,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
if (!nodes.isEmpty()) {
ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
- return ctx.kernalContext().task().execute(
- new ClearTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys), null);
+ return ctx.kernalContext().task().execute(new ClearTask(ctx, keys), null);
}
else
return new GridFinishedFuture<>();
@@ -3573,8 +3571,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
- return ctx.kernalContext().task().execute(
- new SizeTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), peekModes), null);
+ return ctx.kernalContext().task().execute(new SizeTask(ctx, peekModes), null);
}
/** {@inheritDoc} */
@@ -3906,7 +3903,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
READ_COMMITTED,
tCfg.getDefaultTxTimeout(),
!ctx.skipStore(),
- 0
+ 0,
+ /** group lock keys */null,
+ /** partition lock */false
);
assert tx != null;
@@ -3975,7 +3974,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
READ_COMMITTED,
ctx.kernalContext().config().getTransactionConfiguration().getDefaultTxTimeout(),
!ctx.skipStore(),
- 0);
+ 0,
+ null,
+ false);
return asyncOp(tx, op);
}
@@ -4826,6 +4827,13 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
private static final long serialVersionUID = 0L;
/**
+ * Empty constructor for serialization.
+ */
+ public GlobalClearAllJob() {
+ // No-op.
+ }
+
+ /**
* @param cacheName Cache name.
* @param topVer Affinity topology version.
*/
@@ -4851,7 +4859,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
private static final long serialVersionUID = 0L;
/** Keys to remove. */
- private final Set<? extends K> keys;
+ private Set<? extends K> keys;
+
+ /**
+ * Empty constructor for serialization.
+ */
+ public GlobalClearKeySetJob() {
+ // No-op.
+ }
/**
* @param cacheName Cache name.
@@ -4882,7 +4897,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
private static final long serialVersionUID = 0L;
/** Peek modes. */
- private final CachePeekMode[] peekModes;
+ private CachePeekMode[] peekModes;
+
+ /**
+ * Required by {@link Externalizable}.
+ */
+ public SizeJob() {
+ // No-op.
+ }
/**
* @param cacheName Cache name.
@@ -5493,10 +5515,17 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
protected Ignite ignite;
/** Affinity topology version. */
- protected final AffinityTopologyVersion topVer;
+ protected AffinityTopologyVersion topVer;
/** Cache name. */
- protected final String cacheName;
+ protected String cacheName;
+
+ /**
+ * Empty constructor for serialization.
+ */
+ public TopologyVersionAwareJob() {
+ // No-op.
+ }
/**
* @param cacheName Cache name.
@@ -5555,23 +5584,24 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/** */
private static final long serialVersionUID = 0L;
- /** Cache name. */
- private final String cacheName;
-
- /** Affinity topology version. */
- private final AffinityTopologyVersion topVer;
+ /** Cache context. */
+ private GridCacheContext ctx;
/** Peek modes. */
- private final CachePeekMode[] peekModes;
+ private CachePeekMode[] peekModes;
/**
- * @param cacheName Cache name.
- * @param topVer Affinity topology version.
- * @param peekModes Cache peek modes.
+ * Empty constructor for serialization.
*/
- public SizeTask(String cacheName, AffinityTopologyVersion topVer, CachePeekMode[] peekModes) {
- this.cacheName = cacheName;
- this.topVer = topVer;
+ public SizeTask() {
+ // No-op.
+ }
+
+ /**
+ * @param ctx Cache context.
+ */
+ public SizeTask(GridCacheContext ctx, CachePeekMode[] peekModes) {
+ this.ctx = ctx;
this.peekModes = peekModes;
}
@@ -5581,22 +5611,13 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
Map<ComputeJob, ClusterNode> jobs = new HashMap();
for (ClusterNode node : subgrid)
- jobs.put(new SizeJob(cacheName, topVer, peekModes), node);
+ jobs.put(new SizeJob(ctx.name(), ctx.affinity().affinityTopologyVersion(), peekModes), node);
return jobs;
}
/** {@inheritDoc} */
@Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) {
- IgniteException e = res.getException();
-
- if (e != null) {
- if (e instanceof ClusterTopologyException)
- return ComputeJobResultPolicy.WAIT;
-
- throw new IgniteException("Remote job threw exception.", e);
- }
-
return ComputeJobResultPolicy.WAIT;
}
@@ -5620,23 +5641,25 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/** */
private static final long serialVersionUID = 0L;
- /** Cache name. */
- private final String cacheName;
-
- /** Affinity topology version. */
- private final AffinityTopologyVersion topVer;
+ /** Cache context. */
+ private GridCacheContext ctx;
/** Keys to clear. */
- private final Set<? extends K> keys;
+ private Set<? extends K> keys;
/**
- * @param cacheName Cache name.
- * @param topVer Affinity topology version.
+ * Empty constructor for serialization.
+ */
+ public ClearTask() {
+ // No-op.
+ }
+
+ /**
+ * @param ctx Cache context.
* @param keys Keys to clear.
*/
- public ClearTask(String cacheName, AffinityTopologyVersion topVer, Set<? extends K> keys) {
- this.cacheName = cacheName;
- this.topVer = topVer;
+ public ClearTask(GridCacheContext ctx, Set<? extends K> keys) {
+ this.ctx = ctx;
this.keys = keys;
}
@@ -5646,8 +5669,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
Map<ComputeJob, ClusterNode> jobs = new HashMap();
for (ClusterNode node : subgrid) {
- jobs.put(keys == null ? new GlobalClearAllJob(cacheName, topVer) :
- new GlobalClearKeySetJob<K>(cacheName, topVer, keys),
+ jobs.put(keys == null ?
+ new GlobalClearAllJob(ctx.name(), ctx.affinity().affinityTopologyVersion()) :
+ new GlobalClearKeySetJob<K>(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys),
node);
}
@@ -5656,15 +5680,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/** {@inheritDoc} */
@Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) {
- IgniteException e = res.getException();
-
- if (e != null) {
- if (e instanceof ClusterTopologyException)
- return ComputeJobResultPolicy.WAIT;
-
- throw new IgniteException("Remote job threw exception.", e);
- }
-
return ComputeJobResultPolicy.WAIT;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 6f9099f..9bee148 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -1656,13 +1656,6 @@ public class GridCacheContext<K, V> implements Externalizable {
}
/**
- * @return {@code True} if should use entry with offheap value pointer.
- */
- public boolean useOffheapEntry() {
- return cacheCfg.getMemoryMode() == OFFHEAP_TIERED || cacheCfg.getMemoryMode() == OFFHEAP_VALUES;
- }
-
- /**
* Converts temporary offheap object to heap-based.
*
* @param obj Object.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index cbb78e7..1c2f8d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -115,6 +115,9 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
@GridToStringInclude
private final int hash;
+ /** Off-heap value pointer. */
+ protected long valPtr;
+
/** Extras */
@GridToStringInclude
private GridCacheEntryExtras extras;
@@ -185,7 +188,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
if (cctx.cache().isIgfsDataCache() &&
cctx.kernalContext().igfsHelper().isIgfsBlockKey(key.value(cctx.cacheObjectContext(), false))) {
int newSize = valueLength0(val, null);
- int oldSize = valueLength0(this.val, (this.val == null && hasOffHeapPointer()) ? valueBytes0() : null);
+ int oldSize = valueLength0(this.val, (this.val == null && valPtr != 0) ? valueBytes0() : null);
int delta = newSize - oldSize;
@@ -196,7 +199,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
if (!isOffHeapValuesOnly()) {
this.val = val;
- offHeapPointer(0);
+ valPtr = 0;
}
else {
try {
@@ -224,13 +227,12 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
if (val != null) {
byte type = val.type();
- offHeapPointer(mem.putOffHeap(offHeapPointer(), U.toArray(val.valueBytes(cctx.cacheObjectContext())),
- type));
+ valPtr = mem.putOffHeap(valPtr, U.toArray(val.valueBytes(cctx.cacheObjectContext())), type);
}
else {
- mem.removeOffHeap(offHeapPointer());
+ mem.removeOffHeap(valPtr);
- offHeapPointer(0);
+ valPtr = 0;
}
}
catch (IgniteCheckedException e) {
@@ -268,7 +270,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
CacheObject val0 = val;
- if (val0 == null && hasOffHeapPointer()) {
+ if (val0 == null && valPtr != 0) {
IgniteBiTuple<ByteBuffer, Byte> t = valueBytes0();
return cctx.cacheObjects().toCacheObject(cctx.cacheObjectContext(), t.get2(), t.get1());
@@ -432,16 +434,16 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
if (e != null) {
if (e.offheapPointer() > 0) {
- offHeapPointer(e.offheapPointer());
+ valPtr = e.offheapPointer();
if (needVal) {
- CacheObject val = cctx.fromOffheap(offHeapPointer(), false);
+ CacheObject val = cctx.fromOffheap(valPtr, false);
e.value(val);
}
}
else // Read from swap.
- offHeapPointer(0);
+ valPtr = 0;
}
}
else
@@ -466,7 +468,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
// Must update valPtr again since update() will reset it.
if (cctx.offheapTiered() && e.offheapPointer() > 0)
- offHeapPointer(e.offheapPointer());
+ valPtr = e.offheapPointer();
return val;
}
@@ -493,13 +495,13 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
if (cctx.offheapTiered()) {
cctx.swap().removeOffheap(key);
- offHeapPointer(0);
+ valPtr = 0;
}
return;
}
- if (val == null && cctx.offheapTiered() && hasOffHeapPointer()) {
+ if (val == null && cctx.offheapTiered() && valPtr != 0) {
if (log.isDebugEnabled())
log.debug("Value did not change, skip write swap entry: " + this);
@@ -538,10 +540,10 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
protected IgniteBiTuple<ByteBuffer, Byte> valueBytes0() {
assert Thread.holdsLock(this);
- if (hasOffHeapPointer()) {
+ if (valPtr != 0) {
assert isOffHeapValuesOnly() || cctx.offheapTiered();
- IgniteBiTuple<byte[], Byte> t = cctx.unsafeMemory().get(offHeapPointer());
+ IgniteBiTuple<byte[], Byte> t = cctx.unsafeMemory().get(valPtr);
return F.t(ByteBuffer.wrap(t.get1()), t.get2());
}
@@ -672,7 +674,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
CacheObject val = this.val;
- hasOldBytes = hasOffHeapPointer();
+ hasOldBytes = valPtr != 0;
if ((unmarshal || isOffHeapValuesOnly()) && !expired && val == null && hasOldBytes)
val = rawGetOrUnmarshalUnlocked(tmp);
@@ -816,7 +818,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
// Update indexes before actual write to entry.
updateIndex(ret, expTime, nextVer, prevVal);
- boolean hadValPtr = hasOffHeapPointer();
+ boolean hadValPtr = valPtr != 0;
// Don't change version for read-through.
update(ret, expTime, ttl, nextVer);
@@ -964,8 +966,13 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
synchronized (this) {
checkObsolete();
- assert tx == null || (!tx.local() && tx.onePhaseCommit()) || tx.ownsLock(this) :
- "Transaction does not own lock for update [entry=" + this + ", tx=" + tx + ']';
+ if (cctx.kernalContext().config().isCacheSanityCheckEnabled()) {
+ if (tx != null && tx.groupLock())
+ groupLockSanityCheck(tx);
+ else
+ assert tx == null || (!tx.local() && tx.onePhaseCommit()) || tx.ownsLock(this) :
+ "Transaction does not own lock for update [entry=" + this + ", tx=" + tx + ']';
+ }
// Load and remove from swap if it is new.
boolean startVer = isStartVersion();
@@ -1123,7 +1130,10 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
synchronized (this) {
checkObsolete();
- assert tx == null || (!tx.local() && tx.onePhaseCommit()) || tx.ownsLock(this) :
+ if (tx != null && tx.groupLock() && cctx.kernalContext().config().isCacheSanityCheckEnabled())
+ groupLockSanityCheck(tx);
+ else
+ assert tx == null || (!tx.local() && tx.onePhaseCommit()) || tx.ownsLock(this) :
"Transaction does not own lock for remove[entry=" + this + ", tx=" + tx + ']';
boolean startVer = isStartVersion();
@@ -1156,7 +1166,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
// can be updated without actually holding entry lock.
clearIndex(old);
- boolean hadValPtr = hasOffHeapPointer();
+ boolean hadValPtr = valPtr != 0;
update(null, 0, 0, newVer);
@@ -1190,7 +1200,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
obsoleteVer = newVer;
else {
// Only delete entry if the lock is not explicit.
- if (lockedBy(tx.xidVersion()))
+ if (tx.groupLock() || lockedBy(tx.xidVersion()))
obsoleteVer = tx.xidVersion();
else if (log.isDebugEnabled())
log.debug("Obsolete version was not set because lock was explicit: " + this);
@@ -1513,7 +1523,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
// Must persist inside synchronization in non-tx mode.
cctx.store().remove(null, keyValue(false));
- boolean hasValPtr = hasOffHeapPointer();
+ boolean hasValPtr = valPtr != 0;
// Update index inside synchronization since it can be updated
// in load methods without actually holding entry lock.
@@ -2114,7 +2124,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
enqueueVer = newVer;
- boolean hasValPtr = hasOffHeapPointer();
+ boolean hasValPtr = valPtr != 0;
// Clear value on backup. Entry will be removed from cache when it got evicted from queue.
update(null, CU.TTL_ETERNAL, CU.EXPIRE_TIME_ETERNAL, newVer);
@@ -2791,6 +2801,25 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
}
/**
+ * Checks that entries in group locks transactions are not locked during commit.
+ *
+ * @param tx Transaction to check.
+ * @throws GridCacheEntryRemovedException If entry is obsolete.
+ * @throws IgniteCheckedException If entry was externally locked.
+ */
+ private void groupLockSanityCheck(IgniteInternalTx tx) throws GridCacheEntryRemovedException, IgniteCheckedException {
+ assert tx.groupLock();
+
+ IgniteTxEntry txEntry = tx.entry(txKey());
+
+ if (txEntry.groupLockEntry()) {
+ if (lockedByAny())
+ throw new IgniteCheckedException("Failed to update cache entry (entry was externally locked while " +
+ "accessing entry within group lock transaction) [entry=" + this + ", tx=" + tx + ']');
+ }
+ }
+
+ /**
* @param failFast Fail fast flag.
* @param topVer Topology version.
* @param filter Filter.
@@ -2902,8 +2931,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
if (val != null)
return val;
- if (hasOffHeapPointer()) {
- CacheObject val0 = cctx.fromOffheap(offHeapPointer(), tmp);
+ if (valPtr != 0) {
+ CacheObject val0 = cctx.fromOffheap(valPtr, tmp);
if (!tmp && cctx.kernalContext().config().isPeerClassLoadingEnabled())
val0.finishUnmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader());
@@ -2925,7 +2954,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
protected boolean hasValueUnlocked() {
assert Thread.holdsLock(this);
- return val != null || hasOffHeapPointer();
+ return val != null || valPtr != 0;
}
/** {@inheritDoc} */
@@ -3271,7 +3300,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
synchronized (this) {
CacheObject expiredVal = saveValueForIndexUnlocked();
- boolean hasOldBytes = hasOffHeapPointer();
+ boolean hasOldBytes = valPtr != 0;
boolean expired = checkExpired();
@@ -4075,27 +4104,6 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
}
/**
- * @return True if entry has off-heap value pointer.
- */
- protected boolean hasOffHeapPointer() {
- return false;
- }
-
- /**
- * @return Off-heap value pointer.
- */
- protected long offHeapPointer() {
- return 0;
- }
-
- /**
- * @param valPtr Off-heap value pointer.
- */
- protected void offHeapPointer(long valPtr) {
- // No-op.
- }
-
- /**
* @return Size of extras object.
*/
private int extrasSize() {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index c05e4b4..0bb97a9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -510,7 +510,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
* @return Future.
*/
@SuppressWarnings({"unchecked"})
- @Nullable public GridCacheFuture future(GridCacheVersion ver, IgniteUuid futId) {
+ @Nullable public <T> GridCacheFuture<T> future(GridCacheVersion ver, IgniteUuid futId) {
Collection<? extends GridCacheFuture> futs = this.futs.get(ver);
if (futs != null)
@@ -519,7 +519,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
if (log.isDebugEnabled())
log.debug("Found future in futures map: " + fut);
- return fut;
+ return (GridCacheFuture<T>)fut;
}
if (log.isDebugEnabled())
[3/8] incubator-ignite git commit: Revert "ignite-471: fixed NPE in
PortableMarshaller"
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
index 1e85ecd..8410e71 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
@@ -21,7 +21,6 @@ import org.apache.ignite.*;
import org.apache.ignite.internal.managers.deployment.*;
import org.apache.ignite.internal.util.*;
import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
import org.jetbrains.annotations.*;
import org.jsr166.*;
@@ -39,8 +38,20 @@ class GridResourceIoc {
private final ConcurrentMap<ClassLoader, Set<Class<?>>> taskMap =
new ConcurrentHashMap8<>();
- /** Class descriptors cache. */
- private final ConcurrentMap<Class<?>, ClassDescriptor> clsDescs = new ConcurrentHashMap8<>();
+ /** Field cache. */
+ private final ConcurrentMap<Class<?>, ConcurrentMap<Class<? extends Annotation>, GridResourceField[]>> fieldCache =
+ new ConcurrentHashMap8<>();
+
+ /** Method cache. */
+ private final ConcurrentMap<Class<?>, ConcurrentMap<Class<? extends Annotation>, GridResourceMethod[]>> mtdCache =
+ new ConcurrentHashMap8<>();
+
+ /**
+ * Cache for classes that do not require injection with some annotation.
+ * Maps annotation classes to set a set of target classes to skip.
+ */
+ private final ConcurrentMap<Class<? extends Annotation>, Set<Class<?>>> skipCache =
+ new ConcurrentHashMap8<>();
/** */
private final ConcurrentMap<Class<?>, Class<? extends Annotation>[]> annCache =
@@ -53,8 +64,18 @@ class GridResourceIoc {
Set<Class<?>> clss = taskMap.remove(ldr);
if (clss != null) {
- clsDescs.keySet().removeAll(clss);
- annCache.keySet().removeAll(clss);
+ fieldCache.keySet().removeAll(clss);
+ mtdCache.keySet().removeAll(clss);
+
+ for (Map.Entry<Class<? extends Annotation>, Set<Class<?>>> e : skipCache.entrySet()) {
+ Set<Class<?>> skipClss = e.getValue();
+
+ if (skipClss != null)
+ e.getValue().removeAll(clss);
+ }
+
+ for (Class<?> cls : clss)
+ annCache.remove(cls);
}
}
@@ -63,8 +84,8 @@ class GridResourceIoc {
*/
void undeployAll() {
taskMap.clear();
- clsDescs.clear();
- annCache.clear();
+ mtdCache.clear();
+ fieldCache.clear();
}
/**
@@ -86,26 +107,15 @@ class GridResourceIoc {
@Nullable Class<?> depCls)
throws IgniteCheckedException
{
- return injectInternal(target, annCls, injector, dep, depCls, null);
- }
-
- /**
- * @param cls Class.
- */
- private ClassDescriptor descriptor(@Nullable GridDeployment dep, Class<?> cls) {
- ClassDescriptor res = clsDescs.get(cls);
-
- if (res == null) {
- if (dep != null) {
- Set<Class<?>> classes = F.addIfAbsent(taskMap, dep.classLoader(), F.<Class<?>>newCSet());
-
- classes.add(cls);
- }
+ assert target != null;
+ assert annCls != null;
+ assert injector != null;
- res = F.addIfAbsent(clsDescs, cls, new ClassDescriptor(cls));
- }
+ if (isAnnotationPresent(target, annCls, dep))
+ // Use identity hash set to compare via referential equality.
+ return injectInternal(target, annCls, injector, dep, depCls, new GridLeanIdentitySet<>());
- return res;
+ return false;
}
/**
@@ -123,54 +133,73 @@ class GridResourceIoc {
GridResourceInjector injector,
@Nullable GridDeployment dep,
@Nullable Class<?> depCls,
- @Nullable Set<Object> checkedObjs)
+ Set<Object> checkedObjs)
throws IgniteCheckedException
{
- Class<?> targetCls = target.getClass();
+ assert target != null;
+ assert annCls != null;
+ assert injector != null;
+ assert checkedObjs != null;
- ClassDescriptor descr = descriptor(dep, targetCls);
+ Class<?> targetCls = target.getClass();
- T2<GridResourceField[], GridResourceMethod[]> annotatedMembers = descr.annotatedMembers(annCls);
+ Set<Class<?>> skipClss = skipCache.get(annCls);
- if (descr.recursiveFields().length == 0 && annotatedMembers == null)
+ // Skip this class if it does not need to be injected.
+ if (skipClss != null && skipClss.contains(targetCls))
return false;
- if (checkedObjs == null && descr.recursiveFields().length > 0)
- checkedObjs = new GridLeanIdentitySet<>();
-
- if (checkedObjs != null && !checkedObjs.add(target))
+ // Check if already inspected to avoid indefinite recursion.
+ if (!checkedObjs.add(target))
return false;
+ int annCnt = 0;
+
boolean injected = false;
- for (Field field : descr.recursiveFields()) {
- try {
- Object obj = field.get(target);
+ for (GridResourceField field : getFieldsWithAnnotation(dep, targetCls, annCls)) {
+ if (field.processFieldValue()) {
+ Field f = field.getField();
- if (obj != null) {
- assert checkedObjs != null;
+ try {
+ Object obj = f.get(target);
- injected |= injectInternal(obj, annCls, injector, dep, depCls, checkedObjs);
+ if (obj != null) {
+ // Recursion.
+ boolean injected0 = injectInternal(obj, annCls, injector, dep, depCls, checkedObjs);
+
+ injected |= injected0;
+ }
+ }
+ catch (IllegalAccessException e) {
+ throw new IgniteCheckedException("Failed to inject resource [field=" + f.getName() +
+ ", target=" + target + ']', e);
}
}
- catch (IllegalAccessException e) {
- throw new IgniteCheckedException("Failed to inject resource [field=" + field.getName() +
- ", target=" + target + ']', e);
- }
- }
-
- if (annotatedMembers != null) {
- for (GridResourceField field : annotatedMembers.get1()) {
+ else {
injector.inject(field, target, depCls, dep);
injected = true;
}
- for (GridResourceMethod mtd : annotatedMembers.get2()) {
- injector.inject(mtd, target, depCls, dep);
+ annCnt++;
+ }
- injected = true;
- }
+ for (GridResourceMethod mtd : getMethodsWithAnnotation(dep, targetCls, annCls)) {
+ injector.inject(mtd, target, depCls, dep);
+
+ injected = true;
+
+ annCnt++;
+ }
+
+ if (annCnt == 0) {
+ if (skipClss == null)
+ skipClss = F.addIfAbsent(skipCache, annCls, F.<Class<?>>newCSet());
+
+ assert skipClss != null;
+
+ skipClss.add(targetCls);
}
return injected;
@@ -188,9 +217,29 @@ class GridResourceIoc {
assert target != null;
assert annCls != null;
- ClassDescriptor desc = descriptor(dep, target.getClass());
+ Class<?> targetCls = target.getClass();
+
+ Set<Class<?>> skipClss = skipCache.get(annCls);
+
+ if (skipClss != null && skipClss.contains(targetCls))
+ return false;
+
+ GridResourceField[] fields = getFieldsWithAnnotation(dep, targetCls, annCls);
+
+ if (fields.length > 0)
+ return true;
- return desc.recursiveFields().length > 0 || desc.annotatedMembers(annCls) != null;
+ GridResourceMethod[] mtds = getMethodsWithAnnotation(dep, targetCls, annCls);
+
+ if (mtds.length > 0)
+ return true;
+
+ if (skipClss == null)
+ skipClss = F.addIfAbsent(skipCache, annCls, F.<Class<?>>newCSet());
+
+ skipClss.add(targetCls);
+
+ return false;
}
/**
@@ -211,14 +260,17 @@ class GridResourceIoc {
Class<? extends Annotation>[] res = annCache.get(cls);
if (res == null) {
- Collection<Class<? extends Annotation>> res0 = new ArrayList<>();
+ Collection<Class<? extends Annotation>> res0 =
+ new HashSet<>(annClss.size(), 1.0f);
for (Class<? extends Annotation> annCls : annClss) {
if (isAnnotationPresent(target, annCls, dep))
res0.add(annCls);
}
- res = res0.toArray(new Class[res0.size()]);
+ res = new Class[res0.size()];
+
+ res0.toArray(res);
annCache.putIfAbsent(cls, res);
}
@@ -227,6 +279,36 @@ class GridResourceIoc {
}
/**
+ * For tests only.
+ *
+ * @param cls Class for test.
+ * @return {@code true} if cached, {@code false} otherwise.
+ */
+ boolean isCached(Class<?> cls) {
+ return isCached(cls.getName());
+ }
+
+ /**
+ * For tests only.
+ *
+ * @param clsName Class for test.
+ * @return {@code true} if cached, {@code false} otherwise.
+ */
+ boolean isCached(String clsName) {
+ for (Class<?> aClass : fieldCache.keySet()) {
+ if (aClass.getName().equals(clsName))
+ return true;
+ }
+
+ for (Class<?> aClass : mtdCache.keySet()) {
+ if (aClass.getName().equals(clsName))
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
* Gets set of methods with given annotation.
*
* @param dep Deployment.
@@ -236,111 +318,156 @@ class GridResourceIoc {
*/
GridResourceMethod[] getMethodsWithAnnotation(@Nullable GridDeployment dep, Class<?> cls,
Class<? extends Annotation> annCls) {
- ClassDescriptor desc = descriptor(dep, cls);
+ GridResourceMethod[] mtds = getMethodsFromCache(cls, annCls);
- T2<GridResourceField[], GridResourceMethod[]> t2 = desc.annotatedMembers(annCls);
+ if (mtds == null) {
+ List<GridResourceMethod> mtdsList = new ArrayList<>();
- return t2 == null ? GridResourceMethod.EMPTY_ARRAY : t2.get2();
- }
+ for (Class cls0 = cls; !cls0.equals(Object.class); cls0 = cls0.getSuperclass()) {
+ for (Method mtd : cls0.getDeclaredMethods()) {
+ Annotation ann = mtd.getAnnotation(annCls);
- /** {@inheritDoc} */
- public void printMemoryStats() {
- X.println(">>> taskMapSize: " + taskMap.size());
- X.println(">>> classDescriptorsCacheSize: " + clsDescs.size());
+ if (ann != null)
+ mtdsList.add(new GridResourceMethod(mtd, ann));
+ }
+ }
+
+ if (mtdsList.isEmpty())
+ mtds = GridResourceMethod.EMPTY_ARRAY;
+ else
+ mtds = mtdsList.toArray(new GridResourceMethod[mtdsList.size()]);
+
+ cacheMethods(dep, cls, annCls, mtds);
+ }
+
+ return mtds;
}
/**
+ * Gets all entries from the specified class or its super-classes that have
+ * been annotated with annotation provided.
*
+ * @param cls Class in which search for methods.
+ * @param dep Deployment.
+ * @param annCls Annotation.
+ * @return Set of entries with given annotations.
*/
- private static class ClassDescriptor {
- /** */
- private final Field[] recursiveFields;
-
- /** */
- private final Map<Class<? extends Annotation>, T2<GridResourceField[], GridResourceMethod[]>> annMap;
-
- /**
- * @param cls Class.
- */
- ClassDescriptor(Class<?> cls) {
- Map<Class<? extends Annotation>, T2<List<GridResourceField>, List<GridResourceMethod>>> annMap
- = new HashMap<>();
+ private GridResourceField[] getFieldsWithAnnotation(@Nullable GridDeployment dep, Class<?> cls,
+ Class<? extends Annotation> annCls) {
+ GridResourceField[] fields = getFieldsFromCache(cls, annCls);
- List<Field> recursiveFieldsList = new ArrayList<>();
+ if (fields == null) {
+ List<GridResourceField> fieldsList = new ArrayList<>();
boolean allowImplicitInjection = !GridNoImplicitInjection.class.isAssignableFrom(cls);
for (Class cls0 = cls; !cls0.equals(Object.class); cls0 = cls0.getSuperclass()) {
for (Field field : cls0.getDeclaredFields()) {
- Annotation[] fieldAnns = field.getAnnotations();
+ Annotation ann = field.getAnnotation(annCls);
- for (Annotation ann : fieldAnns) {
- T2<List<GridResourceField>, List<GridResourceMethod>> t2 = annMap.get(ann.annotationType());
+ if (ann != null)
+ fieldsList.add(new GridResourceField(field, ann));
+ else if (allowImplicitInjection && GridResourceUtils.mayRequireResources(field)) {
+ // Account for anonymous inner classes.
+ fieldsList.add(new GridResourceField(field, null));
+ }
+ }
+ }
- if (t2 == null) {
- t2 = new T2<List<GridResourceField>, List<GridResourceMethod>>(
- new ArrayList<GridResourceField>(),
- new ArrayList<GridResourceMethod>());
+ if (fieldsList.isEmpty())
+ fields = GridResourceField.EMPTY_ARRAY;
+ else
+ fields = fieldsList.toArray(new GridResourceField[fieldsList.size()]);
- annMap.put(ann.annotationType(), t2);
- }
+ cacheFields(dep, cls, annCls, fields);
+ }
- t2.get1().add(new GridResourceField(field, ann));
- }
+ return fields;
+ }
- if (allowImplicitInjection
- && fieldAnns.length == 0
- && GridResourceUtils.mayRequireResources(field)) {
- field.setAccessible(true);
+ /**
+ * Gets all fields for a given class with given annotation from cache.
+ *
+ * @param cls Class to get fields from.
+ * @param annCls Annotation class for fields.
+ * @return List of fields with given annotation, possibly {@code null}.
+ */
+ @Nullable private GridResourceField[] getFieldsFromCache(Class<?> cls, Class<? extends Annotation> annCls) {
+ Map<Class<? extends Annotation>, GridResourceField[]> annCache = fieldCache.get(cls);
- // Account for anonymous inner classes.
- recursiveFieldsList.add(field);
- }
- }
+ return annCache != null ? annCache.get(annCls) : null;
+ }
- for (Method mtd : cls0.getDeclaredMethods()) {
- for (Annotation ann : mtd.getAnnotations()) {
- T2<List<GridResourceField>, List<GridResourceMethod>> t2 = annMap.get(ann.annotationType());
+ /**
+ * Caches list of fields with given annotation from given class.
+ *
+ * @param cls Class the fields belong to.
+ * @param dep Deployment.
+ * @param annCls Annotation class for the fields.
+ * @param fields Fields to cache.
+ */
+ private void cacheFields(@Nullable GridDeployment dep, Class<?> cls, Class<? extends Annotation> annCls,
+ GridResourceField[] fields) {
+ if (dep != null) {
+ Set<Class<?>> classes = F.addIfAbsent(taskMap, dep.classLoader(), F.<Class<?>>newCSet());
- if (t2 == null) {
- t2 = new T2<List<GridResourceField>, List<GridResourceMethod>>(
- new ArrayList<GridResourceField>(),
- new ArrayList<GridResourceMethod>());
+ assert classes != null;
- annMap.put(ann.annotationType(), t2);
- }
+ classes.add(cls);
+ }
- t2.get2().add(new GridResourceMethod(mtd, ann));
- }
- }
- }
+ Map<Class<? extends Annotation>, GridResourceField[]> rsrcFields =
+ F.addIfAbsent(fieldCache, cls, F.<Class<? extends Annotation>, GridResourceField[]>newCMap());
- recursiveFields = recursiveFieldsList.isEmpty() ? U.EMPTY_FIELDS
- : recursiveFieldsList.toArray(new Field[recursiveFieldsList.size()]);
+ assert rsrcFields != null;
- this.annMap = IgniteUtils.limitedMap(annMap.size());
+ rsrcFields.put(annCls, fields);
+ }
- for (Map.Entry<Class<? extends Annotation>, T2<List<GridResourceField>, List<GridResourceMethod>>> entry
- : annMap.entrySet()) {
- GridResourceField[] fields = GridResourceField.toArray(entry.getValue().get1());
- GridResourceMethod[] mtds = GridResourceMethod.toArray(entry.getValue().get2());
+ /**
+ * Gets all methods for a given class with given annotation from cache.
+ *
+ * @param cls Class to get methods from.
+ * @param annCls Annotation class for fields.
+ * @return List of methods with given annotation, possibly {@code null}.
+ */
+ @Nullable private GridResourceMethod[] getMethodsFromCache(Class<?> cls, Class<? extends Annotation> annCls) {
+ Map<Class<? extends Annotation>, GridResourceMethod[]> annCache = mtdCache.get(cls);
- this.annMap.put(entry.getKey(), new T2<>(fields, mtds));
- }
- }
+ return annCache != null ? annCache.get(annCls) : null;
+ }
- /**
- * @return Recursive fields.
- */
- public Field[] recursiveFields() {
- return recursiveFields;
- }
+ /**
+ * Caches list of methods with given annotation from given class.
+ *
+ * @param rsrcCls Class the fields belong to.
+ * @param dep Deployment.
+ * @param annCls Annotation class for the fields.
+ * @param mtds Methods to cache.
+ */
+ private void cacheMethods(@Nullable GridDeployment dep, Class<?> rsrcCls, Class<? extends Annotation> annCls,
+ GridResourceMethod[] mtds) {
+ if (dep != null) {
+ Set<Class<?>> classes = F.addIfAbsent(taskMap, dep.classLoader(), F.<Class<?>>newCSet());
+
+ assert classes != null;
- /**
- * @return Fields.
- */
- @Nullable public T2<GridResourceField[], GridResourceMethod[]> annotatedMembers(Class<? extends Annotation> annCls) {
- return annMap.get(annCls);
+ classes.add(rsrcCls);
}
+
+ Map<Class<? extends Annotation>, GridResourceMethod[]> rsrcMtds = F.addIfAbsent(mtdCache,
+ rsrcCls, F.<Class<? extends Annotation>, GridResourceMethod[]>newCMap());
+
+ assert rsrcMtds != null;
+
+ rsrcMtds.put(annCls, mtds);
+ }
+
+ /** {@inheritDoc} */
+ public void printMemoryStats() {
+ X.println(">>> taskMapSize: " + taskMap.size());
+ X.println(">>> fieldCacheSize: " + fieldCache.size());
+ X.println(">>> mtdCacheSize: " + mtdCache.size());
+ X.println(">>> skipCacheSize: " + skipCache.size());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceMethod.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceMethod.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceMethod.java
index ad08a40..aba9405 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceMethod.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceMethod.java
@@ -21,7 +21,6 @@ import org.apache.ignite.internal.util.typedef.internal.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
-import java.util.*;
/**
* Wrapper for data where resource should be injected.
@@ -49,8 +48,6 @@ class GridResourceMethod {
this.mtd = mtd;
this.ann = ann;
-
- mtd.setAccessible(true);
}
/**
@@ -71,16 +68,6 @@ class GridResourceMethod {
return ann;
}
- /**
- * @param c Closure.
- */
- public static GridResourceMethod[] toArray(Collection<GridResourceMethod> c) {
- if (c.isEmpty())
- return EMPTY_ARRAY;
-
- return c.toArray(new GridResourceMethod[c.size()]);
- }
-
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridResourceMethod.class, this);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
index f5ba492..f08a287 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
@@ -23,6 +23,7 @@ import org.apache.ignite.compute.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.managers.deployment.*;
import org.apache.ignite.internal.processors.*;
+import org.apache.ignite.internal.util.lang.*;
import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.lifecycle.*;
import org.apache.ignite.resources.*;
@@ -146,8 +147,8 @@ public class GridResourceProcessor extends GridProcessorAdapter {
Method mtd = rsrcMtd.getMethod();
try {
- // No need to call mtd.setAccessible(true);
- // It has been called in GridResourceMethod constructor.
+ mtd.setAccessible(true);
+
mtd.invoke(target);
}
catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
@@ -277,7 +278,7 @@ public class GridResourceProcessor extends GridProcessorAdapter {
log.debug("Injecting resources: " + job);
// Unwrap Proxy object.
- Object obj = unwrapTarget(job);
+ Object obj = unwrapTarget(unwrapJob(job));
injectToJob(dep, taskCls, obj, ses, jobCtx);
@@ -328,6 +329,19 @@ public class GridResourceProcessor extends GridProcessorAdapter {
}
/**
+ * Gets rid of job wrapper, if any.
+ *
+ * @param job Job to unwrap.
+ * @return Unwrapped job.
+ */
+ private ComputeJob unwrapJob(ComputeJob job) {
+ if (job instanceof GridComputeJobWrapper)
+ return ((GridComputeJobWrapper)job).wrappedJob();
+
+ return job;
+ }
+
+ /**
* Injects held resources into given grid task.
*
* @param dep Deployed class.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 80fcbb0..2ab8e0a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -109,13 +109,10 @@ public abstract class IgniteUtils {
private static final int[] GRID_EVTS;
/** Empty integers array. */
- public static final int[] EMPTY_INTS = new int[0];
+ private static final int[] EMPTY_INTS = new int[0];
/** Empty longs. */
- public static final long[] EMPTY_LONGS = new long[0];
-
- /** Empty longs. */
- public static final Field[] EMPTY_FIELDS = new Field[0];
+ private static final long[] EMPTY_LONGS = new long[0];
/** System line separator. */
private static final String NL = System.getProperty("line.separator");
@@ -8859,21 +8856,6 @@ public abstract class IgniteUtils {
}
/**
- * Creates new map that limited by size.
- *
- * @param limit Limit for size.
- */
- public static <K, V> Map<K, V> limitedMap(int limit) {
- if (limit == 0)
- return Collections.emptyMap();
-
- if (limit < 5)
- return new GridLeanMap<>(limit);
-
- return new HashMap<>(capacity(limit), 0.75f);
- }
-
- /**
* Returns comparator that sorts remote node addresses. If remote node resides on the same host, then put
* loopback addresses first, last otherwise.
*
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridComputeJobWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridComputeJobWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridComputeJobWrapper.java
new file mode 100644
index 0000000..82c0078
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridComputeJobWrapper.java
@@ -0,0 +1,96 @@
+/*
+ * 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.util.lang;
+
+import org.apache.ignite.compute.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.jetbrains.annotations.*;
+
+import java.util.concurrent.*;
+
+/**
+ * Convenient wrapper for grid job. It allows to create a job clone in cases when the same
+ * job needs to be cloned to multiple grid nodes during mapping phase of task execution.
+ */
+public class GridComputeJobWrapper implements ComputeJob, Callable<Object>,
+ GridPeerDeployAware {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final ComputeJob job;
+
+ /** Peer deploy aware class. */
+ private transient volatile GridPeerDeployAware p;
+
+ /**
+ * Creates a wrapper with given grid {@code job}.
+ *
+ * @param job Job to wrap.
+ */
+ public GridComputeJobWrapper(ComputeJob job) {
+ A.notNull(job, "job");
+
+ this.job = job;
+ }
+
+ /**
+ * Gets wrapped job.
+ *
+ * @return Wrapped job.
+ */
+ public ComputeJob wrappedJob() {
+ return job;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public final Object call() throws Exception {
+ return execute();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Class<?> deployClass() {
+ if (p == null)
+ p = U.detectPeerDeployAware(this);
+
+ return p.deployClass();
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClassLoader classLoader() {
+ if (p == null)
+ p = U.detectPeerDeployAware(this);
+
+ return p.classLoader();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cancel() {
+ job.cancel();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object execute() {
+ return job.execute();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(GridComputeJobWrapper.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java
index a03d2c8..3f81dc4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.util.nio;
import org.apache.ignite.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
import java.io.*;
import java.nio.*;
@@ -32,6 +33,9 @@ import java.nio.*;
* | MSG_SIZE | MESSAGE | MSG_SIZE | MESSAGE |
* +--+--+--+--+--+--+...+--+--+--+--+--+--+--+...+--+
* </pre>
+ * <p>
+ * It expects that first 4 bytes in stream are {@link U#IGNITE_HEADER}. If beginning of a stream,
+ * isn't equal to these bytes than exception will be thrown.
*/
public class GridBufferedParser implements GridNioParser {
/** Buffer metadata key. */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDelimitedParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDelimitedParser.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDelimitedParser.java
deleted file mode 100644
index 256597c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDelimitedParser.java
+++ /dev/null
@@ -1,91 +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.internal.util.nio;
-
-import org.apache.ignite.*;
-
-import java.io.*;
-import java.nio.*;
-
-/**
- * This class implements stream parser based on {@link GridNioDelimitedBuffer}.
- * <p>
- * The rule for this parser is that every message sent over the stream is appended with
- * delimiter (bytes array). So, the stream structure is as follows:
- * <pre>
- * +--+--+...+--+--+--+--+--+--+--+...+--+--+--+--+--+-
- * | MESSAGE | DELIMITER | MESSAGE | DELIMITER |
- * +--+--+...+--+--+--+--+--+--+--+...+--+--+--+--+--+-
- * </pre>
- */
-public class GridDelimitedParser implements GridNioParser {
- /** Buffer metadata key. */
- private static final int BUF_META_KEY = GridNioSessionMetaKey.nextUniqueKey();
-
- /** Delimiter. */
- private final byte[] delim;
-
- /** Direct buffer. */
- private final boolean directBuf;
-
- /**
- * @param delim Delimiter.
- * @param directBuf Direct buffer.
- */
- public GridDelimitedParser(byte[] delim, boolean directBuf) {
- this.delim = delim;
- this.directBuf = directBuf;
- }
-
- /** {@inheritDoc} */
- @Override public byte[] decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException {
- GridNioDelimitedBuffer nioBuf = ses.meta(BUF_META_KEY);
-
- // Decode for a given session is called per one thread, so there should not be any concurrency issues.
- // However, we make some additional checks.
- if (nioBuf == null) {
- nioBuf = new GridNioDelimitedBuffer(delim);
-
- GridNioDelimitedBuffer old = ses.addMeta(BUF_META_KEY, nioBuf);
-
- assert old == null;
- }
-
- return nioBuf.read(buf);
- }
-
- /** {@inheritDoc} */
- @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException {
- byte[] msg0 = (byte[])msg;
-
- int cap = msg0.length + delim.length;
- ByteBuffer res = directBuf ? ByteBuffer.allocateDirect(cap) : ByteBuffer.allocate(cap);
-
- res.put(msg0);
- res.put(delim);
-
- res.flip();
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return this.getClass().getSimpleName();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBuffer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBuffer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBuffer.java
deleted file mode 100644
index 2b764ec..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBuffer.java
+++ /dev/null
@@ -1,106 +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.internal.util.nio;
-
-import org.jetbrains.annotations.*;
-
-import java.nio.*;
-import java.util.*;
-
-/**
- * Buffer with message delimiter support.
- */
-public class GridNioDelimitedBuffer {
- /** Delimiter. */
- private final byte[] delim;
-
- /** Data. */
- private byte[] data = new byte[16384];
-
- /** Count. */
- private int cnt;
-
- /** Index. */
- private int idx;
-
- /**
- * @param delim Delimiter.
- */
- public GridNioDelimitedBuffer(byte[] delim) {
- assert delim != null;
- assert delim.length > 0;
-
- this.delim = delim;
-
- reset();
- }
-
- /**
- * Resets buffer state.
- */
- private void reset() {
- cnt = 0;
- idx = 0;
- }
-
- /**
- * @param buf Buffer.
- * @return Message bytes or {@code null} if message is not fully read yet.
- */
- @Nullable public byte[] read(ByteBuffer buf) {
- while(buf.hasRemaining()) {
- if (cnt == data.length)
- data = Arrays.copyOf(data, data.length * 2);
-
- byte b = buf.get();
-
- data[cnt++] = b;
-
- if (b == delim[idx])
- idx++;
- else if (idx > 0) {
- int pos = cnt - idx;
-
- idx = 0;
-
- for (int i = pos; i < cnt; i++) {
- if (data[pos] == delim[idx]) {
- pos++;
-
- idx++;
- }
- else {
- pos = cnt - idx;
-
- idx = 0;
- }
- }
- }
-
- if (idx == delim.length) {
- byte[] bytes = Arrays.copyOfRange(data, 0, cnt - delim.length);
-
- reset();
-
- return bytes;
- }
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index fd17791..2d5c541 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -203,7 +203,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
public static final int DFLT_ACK_SND_THRESHOLD = 16;
/** Default socket write timeout. */
- public static final long DFLT_SOCK_WRITE_TIMEOUT = 200;
+ public static final long DFLT_SOCK_WRITE_TIMEOUT = GridNioServer.DFLT_SES_WRITE_TIMEOUT;
/** No-op runnable. */
private static final IgniteRunnable NOOP = new IgniteRunnable() {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 4cff45b..27fa473 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -2689,26 +2689,8 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements TcpDiscov
msgLsnr.apply(msg);
if (redirectToClients(msg)) {
- ByteBuffer marshalledMsg = null;
-
- for (ClientMessageWorker clientMsgWorker : clientMsgWorkers.values()) {
- // Send a clone to client to avoid ConcurrentModificationException
- TcpDiscoveryAbstractMessage msgClone;
-
- try {
- if (marshalledMsg == null)
- marshalledMsg = marsh.marshal(msg);
-
- msgClone = marsh.unmarshal(marshalledMsg, null);
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to marshal message: " + msg, e);
-
- msgClone = msg;
- }
-
- clientMsgWorker.addMessage(msgClone);
- }
+ for (ClientMessageWorker clientMsgWorker : clientMsgWorkers.values())
+ clientMsgWorker.addMessage(msg);
}
Collection<TcpDiscoveryNode> failedNodes;
@@ -3951,6 +3933,18 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements TcpDiscov
long topVer;
if (locNodeCoord) {
+ if (!msg.client() && ipFinder.isShared()) {
+ try {
+ ipFinder.unregisterAddresses(leftNode.socketAddresses());
+ }
+ catch (IgniteSpiException e) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to unregister left node address: " + leftNode);
+
+ onException("Failed to unregister left node address: " + leftNode, e);
+ }
+ }
+
topVer = ring.incrementTopologyVersion();
msg.topologyVersion(topVer);
@@ -4118,6 +4112,20 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements TcpDiscov
long topVer;
if (locNodeCoord) {
+ if (!node.isClient() && ipFinder.isShared()) {
+ try {
+ ipFinder.unregisterAddresses(node.socketAddresses());
+ }
+ catch (IgniteSpiException e) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to unregister failed node address [node=" + node +
+ ", err=" + e.getMessage() + ']');
+
+ onException("Failed to unregister failed node address [node=" + node +
+ ", err=" + e.getMessage() + ']', e);
+ }
+ }
+
topVer = ring.incrementTopologyVersion();
msg.topologyVersion(topVer);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
index c52cbc1..6b3f068 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
@@ -55,11 +55,11 @@ abstract class TcpDiscoverySpiAdapter extends IgniteSpiAdapter implements Discov
/** Default socket operations timeout in milliseconds (value is <tt>200ms</tt>). */
public static final long DFLT_SOCK_TIMEOUT = 200;
- /** Default timeout for receiving message acknowledgement in milliseconds (value is <tt>200ms</tt>). */
- public static final long DFLT_ACK_TIMEOUT = 200;
+ /** Default timeout for receiving message acknowledgement in milliseconds (value is <tt>5,000ms</tt>). */
+ public static final long DFLT_ACK_TIMEOUT = 5000;
- /** Default network timeout in milliseconds (value is <tt>200ms</tt>). */
- public static final long DFLT_NETWORK_TIMEOUT = 200;
+ /** Default network timeout in milliseconds (value is <tt>5,000ms</tt>). */
+ public static final long DFLT_NETWORK_TIMEOUT = 5000;
/** Default value for thread priority (value is <tt>10</tt>). */
public static final int DFLT_THREAD_PRI = 10;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/stream/StreamAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/stream/StreamAdapter.java b/modules/core/src/main/java/org/apache/ignite/stream/StreamAdapter.java
deleted file mode 100644
index 0c4e2d1..0000000
--- a/modules/core/src/main/java/org/apache/ignite/stream/StreamAdapter.java
+++ /dev/null
@@ -1,111 +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.stream;
-
-import org.apache.ignite.*;
-
-import java.util.*;
-
-/**
- * Convenience adapter for streamers. Adapters are optional components for
- * streaming from different data sources. The purpose of adapters is to
- * convert different message formats into Ignite stream key-value tuples
- * and feed the tuples into the provided {@link org.apache.ignite.IgniteDataStreamer}.
- */
-public abstract class StreamAdapter<T, K, V> {
- /** Tuple extractor. */
- private StreamTupleExtractor<T, K, V> extractor;
-
- /** Streamer. */
- private IgniteDataStreamer<K, V> stmr;
-
- /** Ignite. */
- private Ignite ignite;
-
- /**
- * Empty constructor.
- */
- protected StreamAdapter() {
- // No-op.
- }
-
- /**
- * Stream adapter.
- *
- * @param stmr Streamer.
- * @param extractor Tuple extractor.
- */
- protected StreamAdapter(IgniteDataStreamer<K, V> stmr, StreamTupleExtractor<T, K, V> extractor) {
- this.stmr = stmr;
- this.extractor = extractor;
- }
-
- /**
- * @return Provided data streamer.
- */
- public IgniteDataStreamer<K, V> getStreamer() {
- return stmr;
- }
-
- /**
- * @param stmr Ignite data streamer.
- */
- public void setStreamer(IgniteDataStreamer<K, V> stmr) {
- this.stmr = stmr;
- }
-
- /**
- * @return Provided tuple extractor.
- */
- public StreamTupleExtractor<T, K, V> getTupleExtractor() {
- return extractor;
- }
-
- /**
- * @param extractor Extractor for key-value tuples from messages.
- */
- public void setTupleExtractor(StreamTupleExtractor<T, K, V> extractor) {
- this.extractor = extractor;
- }
-
- /**
- * @return Provided {@link Ignite} instance.
- */
- public Ignite getIgnite() {
- return ignite;
- }
-
- /**
- * @param ignite {@link Ignite} instance.
- */
- public void setIgnite(Ignite ignite) {
- this.ignite = ignite;
- }
-
- /**
- * Converts given message to a tuple and adds it to the underlying streamer.
- *
- * @param msg Message to convert.
- */
- protected void addMessage(T msg) {
- Map.Entry<K, V> e = extractor.extract(msg);
-
- if (e != null)
- stmr.addData(e);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/stream/StreamTupleExtractor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/stream/StreamTupleExtractor.java b/modules/core/src/main/java/org/apache/ignite/stream/StreamTupleExtractor.java
deleted file mode 100644
index d2a4ede..0000000
--- a/modules/core/src/main/java/org/apache/ignite/stream/StreamTupleExtractor.java
+++ /dev/null
@@ -1,33 +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.stream;
-
-import java.util.*;
-
-/**
- * Stream tuple extractor to convert messages to Ignite key-value tuples.
- */
-public interface StreamTupleExtractor<T, K, V> {
- /**
- * Extracts a key-value tuple from a message.
- *
- * @param msg Message.
- * @return Key-value tuple.
- */
- public Map.Entry<K, V> extract(T msg);
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java
deleted file mode 100644
index 8161d86..0000000
--- a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketMessageConverter.java
+++ /dev/null
@@ -1,31 +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.stream.socket;
-
-/**
- * Socket message converter.
- */
-public interface SocketMessageConverter<T> {
- /**
- * Converter message represented by array of bytes to object.
- *
- * @param msg Message.
- * @return Converted object.
- */
- public T convert(byte[] msg);
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java b/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
deleted file mode 100644
index d308897..0000000
--- a/modules/core/src/main/java/org/apache/ignite/stream/socket/SocketStreamer.java
+++ /dev/null
@@ -1,218 +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.stream.socket;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.util.nio.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.marshaller.jdk.*;
-import org.apache.ignite.stream.*;
-
-import org.jetbrains.annotations.*;
-
-import java.net.*;
-import java.nio.*;
-
-/**
- * Server that receives data from TCP socket, converts it to key-value pairs using {@link StreamTupleExtractor} and
- * streams into {@link IgniteDataStreamer} instance.
- * <p>
- * By default server uses size-based message processing. That is every message sent over the socket is prepended with
- * 4-byte integer header containing message size. If message delimiter is defined (see {@link #setDelimiter}) then
- * delimiter-based message processing will be used. That is every message sent over the socket is appended with
- * provided delimiter.
- * <p>
- * Received messages through socket converts to Java object using standard serialization. Conversion functionality
- * can be customized via user defined {@link SocketMessageConverter} (e.g. in order to convert messages from
- * non Java clients).
- */
-public class SocketStreamer<T, K, V> extends StreamAdapter<T, K, V> {
- /** Default threads. */
- private static final int DFLT_THREADS = Runtime.getRuntime().availableProcessors();
-
- /** Logger. */
- private IgniteLogger log;
-
- /** Address. */
- private InetAddress addr;
-
- /** Server port. */
- private int port;
-
- /** Threads number. */
- private int threads = DFLT_THREADS;
-
- /** Direct mode. */
- private boolean directMode;
-
- /** Delimiter. */
- private byte[] delim;
-
- /** Converter. */
- private SocketMessageConverter<T> converter;
-
- /** Server. */
- private GridNioServer<byte[]> srv;
-
- /**
- * Sets server address.
- *
- * @param addr Address.
- */
- public void setAddr(InetAddress addr) {
- this.addr = addr;
- }
-
- /**
- * Sets port number.
- *
- * @param port Port.
- */
- public void setPort(int port) {
- this.port = port;
- }
-
- /**
- * Sets threadds amount.
- *
- * @param threads Threads.
- */
- public void setThreads(int threads) {
- this.threads = threads;
- }
-
- /**
- * Sets direct mode flag.
- *
- * @param directMode Direct mode.
- */
- public void setDirectMode(boolean directMode) {
- this.directMode = directMode;
- }
-
- /**
- * Sets message delimiter.
- *
- * @param delim Delimiter.
- */
- public void setDelimiter(byte[] delim) {
- this.delim = delim;
- }
-
- /**
- * Sets message converter.
- *
- * @param converter Converter.
- */
- public void setConverter(SocketMessageConverter<T> converter) {
- this.converter = converter;
- }
-
- /**
- * Starts streamer.
- *
- * @throws IgniteException If failed.
- */
- public void start() {
- A.notNull(getTupleExtractor(), "tupleExtractor");
- A.notNull(getStreamer(), "streamer");
- A.notNull(getIgnite(), "ignite");
- A.ensure(threads > 0, "threads > 0");
-
- log = getIgnite().log();
-
- GridNioServerListener<byte[]> lsnr = new GridNioServerListenerAdapter<byte[]>() {
- @Override public void onConnected(GridNioSession ses) {
- assert ses.accepted();
-
- if (log.isDebugEnabled())
- log.debug("Accepted connection: " + ses.remoteAddress());
- }
-
- @Override public void onDisconnected(GridNioSession ses, @Nullable Exception e) {
- if (e != null)
- log.error("Connection failed with exception", e);
- }
-
- @Override public void onMessage(GridNioSession ses, byte[] msg) {
- addMessage(converter.convert(msg));
- }
- };
-
- ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
-
- GridNioParser parser = F.isEmpty(delim) ? new GridBufferedParser(directMode, byteOrder) :
- new GridDelimitedParser(delim, directMode);
-
- if (converter == null)
- converter = new DefaultConverter<>();
-
- GridNioFilter codec = new GridNioCodecFilter(parser, log, directMode);
-
- GridNioFilter[] filters = new GridNioFilter[] {codec};
-
- try {
- srv = new GridNioServer.Builder<byte[]>()
- .address(addr == null ? InetAddress.getLocalHost() : addr)
- .port(port)
- .listener(lsnr)
- .logger(log)
- .selectorCount(threads)
- .byteOrder(byteOrder)
- .filters(filters)
- .build();
- }
- catch (IgniteCheckedException | UnknownHostException e) {
- throw new IgniteException(e);
- }
-
- srv.start();
-
- if (log.isDebugEnabled())
- log.debug("Socket streaming server started on " + addr + ':' + port);
- }
-
- /**
- * Stops streamer.
- */
- public void stop() {
- srv.stop();
-
- if (log.isDebugEnabled())
- log.debug("Socket streaming server stopped");
- }
-
- /**
- * Converts message to Java object using Jdk marshaller.
- */
- private static class DefaultConverter<T> implements SocketMessageConverter<T> {
- /** Marshaller. */
- private static final JdkMarshaller MARSH = new JdkMarshaller();
-
- /** {@inheritDoc} */
- @Override public T convert(byte[] msg) {
- try {
- return MARSH.unmarshal(ByteBuffer.wrap(msg), null);
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException(e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/java/org/apache/ignite/stream/socket/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/stream/socket/package-info.java b/modules/core/src/main/java/org/apache/ignite/stream/socket/package-info.java
deleted file mode 100644
index e1cef65..0000000
--- a/modules/core/src/main/java/org/apache/ignite/stream/socket/package-info.java
+++ /dev/null
@@ -1,21 +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.
- */
-
-/**
- * Contains socket streamer implementation.
- */
-package org.apache.ignite.stream.socket;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index 4f4c1ae..1d4a652 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -1140,6 +1140,7 @@ org.apache.ignite.internal.util.lang.GridAbsClosure
org.apache.ignite.internal.util.lang.GridAbsClosureX
org.apache.ignite.internal.util.lang.GridCloseableIterator
org.apache.ignite.internal.util.lang.GridClosureException
+org.apache.ignite.internal.util.lang.GridComputeJobWrapper
org.apache.ignite.internal.util.lang.GridFunc$1
org.apache.ignite.internal.util.lang.GridFunc$10
org.apache.ignite.internal.util.lang.GridFunc$100
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java
deleted file mode 100644
index 8c7d33d..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java
+++ /dev/null
@@ -1,168 +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.internal.processors.cache;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.*;
-import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.*;
-import org.apache.ignite.internal.processors.cache.distributed.near.*;
-import org.apache.ignite.internal.processors.cache.local.*;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.cache.CacheMemoryMode.*;
-import static org.apache.ignite.cache.CacheMode.*;
-
-/**
- * Cache map entry self test.
- */
-public class CacheOffheapMapEntrySelfTest extends GridCacheAbstractSelfTest {
- /** {@inheritDoc} */
- @Override protected int gridCount() {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- startGrids(1);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- // No-op.
- }
-
- /**
- * @param gridName Grid name.
- * @param memoryMode Memory mode.
- * @param atomicityMode Atomicity mode.
- * @param cacheMode Cache mode.
- * @param cacheName Cache name.
- * @return Cache configuration.
- * @throws Exception If failed.
- */
- private CacheConfiguration cacheConfiguration(String gridName,
- CacheMemoryMode memoryMode,
- CacheAtomicityMode atomicityMode,
- CacheMode cacheMode,
- String cacheName)
- throws Exception
- {
- CacheConfiguration cfg = super.cacheConfiguration(gridName);
-
- cfg.setCacheMode(cacheMode);
- cfg.setAtomicityMode(atomicityMode);
- cfg.setMemoryMode(memoryMode);
- cfg.setName(cacheName);
-
- return cfg;
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheMapEntry() throws Exception {
- checkCacheMapEntry(ONHEAP_TIERED, ATOMIC, LOCAL, GridLocalCacheEntry.class);
-
- checkCacheMapEntry(OFFHEAP_TIERED, ATOMIC, LOCAL, GridLocalCacheEntry.class);
-
- checkCacheMapEntry(OFFHEAP_VALUES, ATOMIC, LOCAL, GridLocalCacheEntry.class);
-
- checkCacheMapEntry(ONHEAP_TIERED, TRANSACTIONAL, LOCAL, GridLocalCacheEntry.class);
-
- checkCacheMapEntry(OFFHEAP_TIERED, TRANSACTIONAL, LOCAL, GridLocalCacheEntry.class);
-
- checkCacheMapEntry(OFFHEAP_VALUES, TRANSACTIONAL, LOCAL, GridLocalCacheEntry.class);
-
- checkCacheMapEntry(ONHEAP_TIERED, ATOMIC, PARTITIONED, GridNearCacheEntry.class);
-
- checkCacheMapEntry(OFFHEAP_TIERED, ATOMIC, PARTITIONED, GridNearOffHeapCacheEntry.class);
-
- checkCacheMapEntry(OFFHEAP_VALUES, ATOMIC, PARTITIONED, GridNearOffHeapCacheEntry.class);
-
- checkCacheMapEntry(ONHEAP_TIERED, TRANSACTIONAL, PARTITIONED, GridNearCacheEntry.class);
-
- checkCacheMapEntry(OFFHEAP_TIERED, TRANSACTIONAL, PARTITIONED, GridNearOffHeapCacheEntry.class);
-
- checkCacheMapEntry(OFFHEAP_VALUES, TRANSACTIONAL, PARTITIONED, GridNearOffHeapCacheEntry.class);
-
- checkCacheMapEntry(ONHEAP_TIERED, ATOMIC, REPLICATED, GridDhtAtomicCacheEntry.class);
-
- checkCacheMapEntry(OFFHEAP_TIERED, ATOMIC, REPLICATED, GridDhtAtomicOffHeapCacheEntry.class);
-
- checkCacheMapEntry(OFFHEAP_VALUES, ATOMIC, REPLICATED, GridDhtAtomicOffHeapCacheEntry.class);
-
- checkCacheMapEntry(ONHEAP_TIERED, TRANSACTIONAL, REPLICATED, GridDhtColocatedCacheEntry.class);
-
- checkCacheMapEntry(OFFHEAP_TIERED, TRANSACTIONAL, REPLICATED, GridDhtColocatedOffHeapCacheEntry.class);
-
- checkCacheMapEntry(OFFHEAP_VALUES, TRANSACTIONAL, REPLICATED, GridDhtColocatedOffHeapCacheEntry.class);
- }
-
- /**
- * @param memoryMode Cache memory mode.
- * @param atomicityMode Cache atomicity mode.
- * @param cacheMode Cache mode.
- * @param entryCls Class of cache map entry.
- * @throws Exception If failed.
- */
- private void checkCacheMapEntry(CacheMemoryMode memoryMode,
- CacheAtomicityMode atomicityMode,
- CacheMode cacheMode,
- Class<?> entryCls)
- throws Exception
- {
- log.info("Test cache [memMode=" + memoryMode +
- ", atomicityMode=" + atomicityMode +
- ", cacheMode=" + cacheMode + ']');
-
- CacheConfiguration cfg = cacheConfiguration(grid(0).name(),
- memoryMode,
- atomicityMode,
- cacheMode,
- "Cache");
-
- try (IgniteCache jcache = grid(0).getOrCreateCache(cfg)) {
- GridCacheAdapter<Integer, String> cache = ((IgniteKernal)grid(0)).internalCache(jcache.getName());
-
- Integer key = primaryKey(grid(0).cache(null));
-
- cache.put(key, "val");
-
- GridCacheEntryEx entry = cache.entryEx(key);
-
- entry.unswap(true);
-
- assertNotNull(entry);
-
- assertEquals(entry.getClass(), entryCls);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRemoveAllSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRemoveAllSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRemoveAllSelfTest.java
deleted file mode 100644
index f5de96f..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRemoveAllSelfTest.java
+++ /dev/null
@@ -1,81 +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.internal.processors.cache;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.testframework.*;
-
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-/**
- * Test remove all method.
- */
-public class CacheRemoveAllSelfTest extends GridCacheAbstractSelfTest {
- /** {@inheritDoc} */
- @Override protected long getTestTimeout() {
- return 60000;
- }
-
- /** {@inheritDoc} */
- @Override protected int gridCount() {
- return 4;
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testRemoveAll() throws Exception {
- IgniteCache<Integer, String> cache = grid(0).cache(null);
-
- for (int i = 0; i < 10_000; ++i)
- cache.put(i, "val");
-
- final AtomicInteger igniteId = new AtomicInteger(gridCount());
-
- IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
- @Override public Object call() throws Exception {
- for (int i = 0; i < 2; ++i)
- startGrid(igniteId.getAndIncrement());
-
- return true;
- }
- }, 3, "start-node-thread");
-
- cache.removeAll();
-
- fut.get();
-
- U.sleep(5000);
-
- for (int i = 0; i < igniteId.get(); ++i) {
- IgniteCache locCache = grid(i).cache(null);
-
- assertEquals("Local size: " + locCache.localSize() + "\n" +
- "On heap: " + locCache.localSize(CachePeekMode.ONHEAP) + "\n" +
- "Off heap: " + locCache.localSize(CachePeekMode.OFFHEAP) + "\n" +
- "Swap: " + locCache.localSize(CachePeekMode.SWAP) + "\n" +
- "Primary: " + locCache.localSize(CachePeekMode.PRIMARY) + "\n" +
- "Backup: " + locCache.localSize(CachePeekMode.BACKUP),
- 0, locCache.localSize());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
index 5d9ad35..5389ef9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
@@ -25,12 +25,12 @@ import org.apache.ignite.internal.cluster.*;
import org.apache.ignite.internal.util.lang.*;
import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.testframework.*;
import org.apache.ignite.transactions.*;
import org.jetbrains.annotations.*;
import javax.cache.*;
+import java.util.*;
import java.util.concurrent.atomic.*;
import static org.apache.ignite.cache.CacheRebalanceMode.*;
@@ -70,12 +70,6 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac
cfg.getTransactionConfiguration().setTxSerializableEnabled(true);
- TcpDiscoverySpi discoSpi = (TcpDiscoverySpi)cfg.getDiscoverySpi();
-
- discoSpi.setSocketTimeout(10_000);
- discoSpi.setAckTimeout(10_000);
- discoSpi.setNetworkTimeout(10_000);
-
return cfg;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
index 7e65f23..85e2c7c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache.distributed;
import org.apache.ignite.*;
import org.apache.ignite.cache.*;
+import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
@@ -105,10 +106,6 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
disco.setIpFinder(ipFinder);
- disco.setSocketTimeout(30_000);
- disco.setAckTimeout(30_000);
- disco.setNetworkTimeout(30_000);
-
c.setDiscoverySpi(disco);
return c;
@@ -515,7 +512,7 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
try {
cache.put(key, Integer.toString(key));
}
- catch (IgniteException | CacheException ignored) {
+ catch (TransactionRollbackException | ClusterTopologyException | CacheException ignored) {
// It is ok if primary node leaves grid.
}
@@ -671,7 +668,7 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
tx.commit();
}
}
- catch (IgniteException | CacheException ignored) {
+ catch (ClusterTopologyException | CacheException ignored) {
// It is ok if primary node leaves grid.
}
@@ -817,7 +814,7 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
tx.commit();
}
- catch (IgniteException | CacheException ignored) {
+ catch (ClusterTopologyException | CacheException ignored) {
// It is ok if primary node leaves grid.
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java
index 2fe76e7..ab0f7d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java
@@ -501,6 +501,8 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest {
* @throws Throwable If failed.
*/
public void testLockReentrancy() throws Throwable {
+ fail("https://issues.apache.org/jira/browse/IGNITE-835");
+
Affinity<Integer> aff = ignite1.affinity(null);
for (int i = 10; i < 100; i++) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxGetAfterStopTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxGetAfterStopTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxGetAfterStopTest.java
deleted file mode 100644
index 469f513..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxGetAfterStopTest.java
+++ /dev/null
@@ -1,131 +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.internal.processors.cache.distributed;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.transactions.*;
-import org.jetbrains.annotations.*;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.cache.CacheMode.*;
-
-/**
- *
- */
-public class IgniteTxGetAfterStopTest extends IgniteCacheAbstractTest {
- /** */
- private CacheMode cacheMode;
-
- /** */
- private NearCacheConfiguration nearCfg;
-
- /** {@inheritDoc} */
- @Override protected int gridCount() {
- return 4;
- }
-
- /** {@inheritDoc} */
- @Override protected CacheMode cacheMode() {
- return cacheMode;
- }
-
- /** {@inheritDoc} */
- @Override protected CacheAtomicityMode atomicityMode() {
- return TRANSACTIONAL;
- }
-
- /** {@inheritDoc} */
- @Override protected NearCacheConfiguration nearConfiguration() {
- return nearCfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- stopAllGrids();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testReplicated() throws Exception {
- getAfterStop(REPLICATED, null);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPartitioned() throws Exception {
- getAfterStop(PARTITIONED, new NearCacheConfiguration());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPartitionedNearDisabled() throws Exception {
- getAfterStop(PARTITIONED, null);
- }
-
- /**
- * @param cacheMode Cache mode.
- * @param nearCfg Near cache configuration.
- * @throws Exception If failed.
- */
- private void getAfterStop(CacheMode cacheMode, @Nullable NearCacheConfiguration nearCfg) throws Exception {
- this.cacheMode = cacheMode;
- this.nearCfg = nearCfg;
-
- startGrids();
-
- IgniteCache<Integer, Integer> cache0 = jcache(0);
- IgniteCache<Integer, Integer> cache1 = jcache(1);
-
- Integer key0 = primaryKey(cache0);
- Integer key1 = primaryKey(cache1);
-
- try (Transaction tx = ignite(0).transactions().txStart()) {
- log.info("Put: " + key0);
-
- cache0.put(key0, key0);
-
- log.info("Stop node.");
-
- stopGrid(3);
-
- log.info("Get: " + key1);
-
- cache0.get(key1);
-
- log.info("Commit.");
-
- tx.commit();
- }
-
- assertEquals(key0, cache0.get(key0));
- assertNull(cache1.get(key1));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java
deleted file mode 100644
index 69c7909..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java
+++ /dev/null
@@ -1,47 +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.internal.processors.cache.distributed.dht;
-
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.processors.cache.distributed.near.*;
-
-/**
- *
- */
-public class GridCachePartitionedNearDisabledLockSelfTest extends GridCachePartitionedLockSelfTest {
- /** {@inheritDoc} */
- @Override protected CacheConfiguration cacheConfiguration() {
- CacheConfiguration ccfg = super.cacheConfiguration();
-
- assertNotNull(ccfg.getNearConfiguration());
-
- ccfg.setNearConfiguration(null);
-
- return ccfg;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean isPartitioned() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public void testLockReentrancy() throws Throwable {
- fail("https://issues.apache.org/jira/browse/IGNITE-835");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePrimaryNodeFailureRecoveryAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePrimaryNodeFailureRecoveryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePrimaryNodeFailureRecoveryAbstractTest.java
index f996877..ee2f16b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePrimaryNodeFailureRecoveryAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePrimaryNodeFailureRecoveryAbstractTest.java
@@ -199,7 +199,7 @@ public abstract class IgniteCachePrimaryNodeFailureRecoveryAbstractTest extends
commSpi.blockMessages(ignite(2).cluster().localNode().id()); // Do not allow to finish prepare for key2.
- IgniteInternalFuture<?> prepFut = txEx.prepareAsync();
+ IgniteInternalFuture<IgniteInternalTx> prepFut = txEx.prepareAsync();
waitPrepared(ignite(1));
@@ -360,7 +360,7 @@ public abstract class IgniteCachePrimaryNodeFailureRecoveryAbstractTest extends
commSpi.blockMessages(ignite(2).cluster().localNode().id()); // Do not allow to finish prepare for key2.
- IgniteInternalFuture<?> prepFut = txEx.prepareAsync();
+ IgniteInternalFuture<IgniteInternalTx> prepFut = txEx.prepareAsync();
waitPrepared(ignite(1));
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a6dd007/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicReplicatedFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicReplicatedFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicReplicatedFailoverSelfTest.java
index 1e57c09..0a2781b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicReplicatedFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicReplicatedFailoverSelfTest.java
@@ -18,7 +18,6 @@
package org.apache.ignite.internal.processors.cache.distributed.dht.atomic;
import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
import static org.apache.ignite.cache.CacheMode.*;
@@ -30,9 +29,4 @@ public class GridCacheAtomicReplicatedFailoverSelfTest extends GridCacheAtomicFa
@Override protected CacheMode cacheMode() {
return REPLICATED;
}
-
- /** {@inheritDoc} */
- @Override protected NearCacheConfiguration nearConfiguration() {
- return null;
- }
}