You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/03/17 14:49:58 UTC
[01/16] ignite git commit: IGNITE-3207 Fix .NET
ConsoleRedirectTest.TestMultipleDomains
Repository: ignite
Updated Branches:
refs/heads/ignite-4565-ddl 636048f33 -> 70a11912b
IGNITE-3207 Fix .NET ConsoleRedirectTest.TestMultipleDomains
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/be93baa7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/be93baa7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/be93baa7
Branch: refs/heads/ignite-4565-ddl
Commit: be93baa755447e5eef95e11ba43d4468bf5be31e
Parents: 5db0c02
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Wed Mar 15 13:32:50 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Wed Mar 15 13:32:50 2017 +0300
----------------------------------------------------------------------
.../dotnet/Apache.Ignite.Core.Tests/ConsoleRedirectTest.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/be93baa7/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ConsoleRedirectTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ConsoleRedirectTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ConsoleRedirectTest.cs
index bb44dcc..3884cab 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ConsoleRedirectTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ConsoleRedirectTest.cs
@@ -118,7 +118,7 @@ namespace Apache.Ignite.Core.Tests
var outTxt = _outSb.ToString();
// Check output from another domain (2 started + 2 stopped = 4)
- Assert.AreEqual(4, Regex.Matches(outTxt, ">>> Grid name: newDomainGrid").Count);
+ Assert.AreEqual(4, Regex.Matches(outTxt, ">>> Ignite instance name: newDomainGrid").Count);
// Both domains produce the topology snapshot on node enter
Assert.AreEqual(2, Regex.Matches(outTxt, "ver=2, servers=2, clients=0,").Count);
[05/16] ignite git commit: IGNITE-824: Removed
GridRandomSelfTest.testPerformance(). This closes #1566.
Posted by vo...@apache.org.
IGNITE-824: Removed GridRandomSelfTest.testPerformance(). This closes #1566.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cd0bc4fd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cd0bc4fd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cd0bc4fd
Branch: refs/heads/ignite-4565-ddl
Commit: cd0bc4fd5bed636a796e22288f8d027234dfca38
Parents: 5db0c02
Author: Alexander Menshikov <sh...@gmail.com>
Authored: Thu Mar 16 14:49:45 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Thu Mar 16 14:49:45 2017 +0300
----------------------------------------------------------------------
.../org/apache/ignite/util/GridRandomSelfTest.java | 16 ----------------
1 file changed, 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/cd0bc4fd/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java
index fee8824..1310c4e 100644
--- a/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java
@@ -51,20 +51,4 @@ public class GridRandomSelfTest extends TestCase {
}
}
}
-
- /**
- * Test performance difference.
- */
- public void testPerformance() {
- fail("https://issues.apache.org/jira/browse/IGNITE-824");
-
- Random rnd = new GridRandom(); // new Random();
-
- long start = System.nanoTime();
-
- for (int i = 0; i < 2000000000; i++)
- rnd.nextInt();
-
- X.println("Time: " + (System.nanoTime() - start) + " ns");
- }
}
\ No newline at end of file
[03/16] ignite git commit: IGNITE-4716 .NET: Add IgniteUuid system
type support
Posted by vo...@apache.org.
IGNITE-4716 .NET: Add IgniteUuid system type support
This closes #1618
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8e5e3cbf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8e5e3cbf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8e5e3cbf
Branch: refs/heads/ignite-4565-ddl
Commit: 8e5e3cbf35976fc57652906f26c86e25a561b41a
Parents: 637c18d
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Wed Mar 15 14:04:31 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Wed Mar 15 14:04:31 2017 +0300
----------------------------------------------------------------------
.../platform/PlatformContextImpl.java | 10 ++---
.../platform/PlatformComputeEchoTask.java | 6 +++
.../Binary/BinaryReaderWriterTest.cs | 8 ++++
.../Compute/ComputeApiTest.cs | 19 ++++++++
.../Apache.Ignite.Core/Common/IgniteGuid.cs | 47 +++++++++++++-------
.../Apache.Ignite.Core/Events/CacheEvent.cs | 2 +-
.../Apache.Ignite.Core/Events/EventBase.cs | 4 +-
.../Apache.Ignite.Core/Events/JobEvent.cs | 4 +-
.../Apache.Ignite.Core/Events/TaskEvent.cs | 2 +-
.../Impl/Binary/BinaryReader.cs | 4 +-
.../Impl/Binary/BinarySystemHandlers.cs | 2 +-
.../Impl/Binary/BinaryUtils.cs | 11 +++--
.../Impl/Binary/Marshaller.cs | 4 +-
13 files changed, 88 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
index 6cec7a1..8f7d5de 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
@@ -510,7 +510,7 @@ public class PlatformContextImpl implements PlatformContext {
writer.writeBoolean(event0.isNear());
writeNode(writer, event0.eventNode());
writer.writeObject(event0.key());
- PlatformUtils.writeIgniteUuid(writer, event0.xid());
+ writer.writeObject(event0.xid());
writer.writeObject(event0.newValue());
writer.writeObject(event0.oldValue());
writer.writeBoolean(event0.hasOldValue());
@@ -589,8 +589,8 @@ public class PlatformContextImpl implements PlatformContext {
writer.writeString(event0.taskName());
writer.writeString(event0.taskClassName());
- PlatformUtils.writeIgniteUuid(writer, event0.taskSessionId());
- PlatformUtils.writeIgniteUuid(writer, event0.jobId());
+ writer.writeObject(event0.taskSessionId());
+ writer.writeObject(event0.jobId());
writeNode(writer, event0.taskNode());
writer.writeUuid(event0.taskSubjectId());
}
@@ -610,7 +610,7 @@ public class PlatformContextImpl implements PlatformContext {
writer.writeString(event0.taskName());
writer.writeString(event0.taskClassName());
- PlatformUtils.writeIgniteUuid(writer, event0.taskSessionId());
+ writer.writeObject(event0.taskSessionId());
writer.writeBoolean(event0.internal());
writer.writeUuid(event0.subjectId());
}
@@ -625,7 +625,7 @@ public class PlatformContextImpl implements PlatformContext {
* @param evt Event.
*/
private void writeCommonEventData(BinaryRawWriterEx writer, EventAdapter evt) {
- PlatformUtils.writeIgniteUuid(writer, evt.id());
+ writer.writeObject(evt.id());
writer.writeLong(evt.localOrder());
writeNode(writer, evt.node());
writer.writeString(evt.message());
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
index 036491f..540daa2 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
@@ -107,6 +107,9 @@ public class PlatformComputeEchoTask extends ComputeTaskAdapter<Integer, Object>
/** Type: enum array from cache. */
private static final int TYPE_ENUM_ARRAY_FROM_CACHE = 21;
+ /** Type: ignite uuid. */
+ private static final int TYPE_IGNITE_UUID = 22;
+
/** {@inheritDoc} */
@Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
@Nullable Integer arg) {
@@ -219,6 +222,9 @@ public class PlatformComputeEchoTask extends ComputeTaskAdapter<Integer, Object>
case TYPE_AFFINITY_KEY:
return new AffinityKey<>("interopAffinityKey");
+ case TYPE_IGNITE_UUID:
+ return ignite.cache(null).get(TYPE_IGNITE_UUID);
+
default:
throw new IgniteException("Unknown type: " + type);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs
index c17caff..ffbd084 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs
@@ -92,12 +92,14 @@ namespace Apache.Ignite.Core.Tests.Binary
writer.WriteDouble("Double", 1);
writer.WriteDoubleArray("DoubleArray", new double[] {1});
writer.WriteDecimal("Decimal", 1);
+ writer.WriteDecimal("DecimalN", null);
writer.WriteDecimalArray("DecimalArray", new decimal?[] {1});
writer.WriteTimestamp("Timestamp", Date);
writer.WriteTimestampArray("TimestampArray", new DateTime?[] {Date});
writer.WriteString("String", "1");
writer.WriteStringArray("StringArray", new[] {"1"});
writer.WriteGuid("Guid", Guid);
+ writer.WriteGuid("GuidN", null);
writer.WriteGuidArray("GuidArray", new Guid?[] {Guid});
writer.WriteEnum("Enum", MyEnum.Bar);
writer.WriteEnumArray("EnumArray", new[] {MyEnum.Bar});
@@ -121,12 +123,14 @@ namespace Apache.Ignite.Core.Tests.Binary
raw.WriteDouble(1);
raw.WriteDoubleArray(new double[] {1});
raw.WriteDecimal(1);
+ raw.WriteDecimal(null);
raw.WriteDecimalArray(new decimal?[] {1});
raw.WriteTimestamp(Date);
raw.WriteTimestampArray(new DateTime?[] {Date});
raw.WriteString("1");
raw.WriteStringArray(new[] {"1"});
raw.WriteGuid(Guid);
+ raw.WriteGuid(null);
raw.WriteGuidArray(new Guid?[] {Guid});
raw.WriteEnum(MyEnum.Bar);
raw.WriteEnumArray(new[] {MyEnum.Bar});
@@ -151,12 +155,14 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(1, reader.ReadDouble("Double"));
Assert.AreEqual(new double[] {1}, reader.ReadDoubleArray("DoubleArray"));
Assert.AreEqual(1, reader.ReadDecimal("Decimal"));
+ Assert.AreEqual(null, reader.ReadDecimal("DecimalN"));
Assert.AreEqual(new decimal?[] {1}, reader.ReadDecimalArray("DecimalArray"));
Assert.AreEqual(Date, reader.ReadTimestamp("Timestamp"));
Assert.AreEqual(new DateTime?[] {Date}, reader.ReadTimestampArray("TimestampArray"));
Assert.AreEqual("1", reader.ReadString("String"));
Assert.AreEqual(new[] {"1"}, reader.ReadStringArray("StringArray"));
Assert.AreEqual(Guid, reader.ReadGuid("Guid"));
+ Assert.AreEqual(null, reader.ReadGuid("GuidN"));
Assert.AreEqual(new Guid?[] {Guid}, reader.ReadGuidArray("GuidArray"));
Assert.AreEqual(MyEnum.Bar, reader.ReadEnum<MyEnum>("Enum"));
Assert.AreEqual(new[] {MyEnum.Bar}, reader.ReadEnumArray<MyEnum>("EnumArray"));
@@ -180,12 +186,14 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(1, raw.ReadDouble());
Assert.AreEqual(new double[] { 1 }, raw.ReadDoubleArray());
Assert.AreEqual(1, raw.ReadDecimal());
+ Assert.AreEqual(null, raw.ReadDecimal());
Assert.AreEqual(new decimal?[] { 1 }, raw.ReadDecimalArray());
Assert.AreEqual(Date, raw.ReadTimestamp());
Assert.AreEqual(new DateTime?[] { Date }, raw.ReadTimestampArray());
Assert.AreEqual("1", raw.ReadString());
Assert.AreEqual(new[] { "1" }, raw.ReadStringArray());
Assert.AreEqual(Guid, raw.ReadGuid());
+ Assert.AreEqual(null, raw.ReadGuid());
Assert.AreEqual(new Guid?[] { Guid }, raw.ReadGuidArray());
Assert.AreEqual(MyEnum.Bar, raw.ReadEnum<MyEnum>());
Assert.AreEqual(new[] { MyEnum.Bar }, raw.ReadEnumArray<MyEnum>());
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
index da3ef1a..0125466 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -118,6 +118,9 @@ namespace Apache.Ignite.Core.Tests.Compute
/** Type: enum array from cache. */
private const int EchoTypeEnumArrayFromCache = 21;
+
+ /** Echo type: IgniteUuid. */
+ private const int EchoTypeIgniteUuid = 22;
/** First node. */
private IIgnite _grid1;
@@ -1032,6 +1035,22 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
+ /// Tests that IgniteGuid in .NET maps to IgniteUuid in Java.
+ /// </summary>
+ [Test]
+ public void TestEchoTaskIgniteUuid()
+ {
+ var guid = Guid.NewGuid();
+
+ _grid1.GetCache<int, object>(null)[EchoTypeIgniteUuid] = new IgniteGuid(guid, 25);
+
+ var res = _grid1.GetCompute().ExecuteJavaTask<IgniteGuid>(EchoTask, EchoTypeIgniteUuid);
+
+ Assert.AreEqual(guid, res.GlobalId);
+ Assert.AreEqual(25, res.LocalId);
+ }
+
+ /// <summary>
/// Test for binary argument in Java.
/// </summary>
[Test]
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
index 10fbb2e..b686f9b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
@@ -18,14 +18,16 @@
namespace Apache.Ignite.Core.Common
{
using System;
+ using System.Diagnostics;
using System.Globalization;
using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
/// <summary>
/// Ignite guid with additional local ID.
/// </summary>
[Serializable]
- public struct IgniteGuid : IEquatable<IgniteGuid>
+ public struct IgniteGuid : IEquatable<IgniteGuid>, IBinaryWriteAware
{
/** Global id. */
private readonly Guid _globalId;
@@ -45,6 +47,20 @@ namespace Apache.Ignite.Core.Common
}
/// <summary>
+ /// Initializes a new instance of the <see cref="IgniteGuid"/> struct.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal IgniteGuid(IBinaryRawReader reader)
+ {
+ Debug.Assert(reader != null);
+
+ var stream = ((BinaryReader) reader).Stream;
+
+ _localId = stream.ReadLong();
+ _globalId = BinaryUtils.ReadGuid(stream);
+ }
+
+ /// <summary>
/// Gets the global id.
/// </summary>
public Guid GlobalId
@@ -90,20 +106,6 @@ namespace Apache.Ignite.Core.Common
}
/// <summary>
- /// Reads this object from the given reader.
- /// </summary>
- /// <param name="r">Reader.</param>
- internal static IgniteGuid? Read(IBinaryRawReader r)
- {
- var guid = r.ReadGuid();
-
- if (guid == null)
- return null;
-
- return new IgniteGuid(guid.Value, r.ReadLong());
- }
-
- /// <summary>
/// Implements the operator ==.
/// </summary>
/// <param name="a">First item.</param>
@@ -128,5 +130,20 @@ namespace Apache.Ignite.Core.Common
{
return !(a == b);
}
+
+ /// <summary>
+ /// Writes this object to the given writer.
+ /// </summary>
+ /// <param name="writer">Writer.</param>
+ /// <exception cref="System.NotImplementedException"></exception>
+ void IBinaryWriteAware.WriteBinary(IBinaryWriter writer)
+ {
+ Debug.Assert(writer != null);
+
+ var stream = ((BinaryWriter) writer.GetRawWriter()).Stream;
+
+ stream.WriteLong(_localId);
+ BinaryUtils.WriteGuid(_globalId, stream);
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
index ec22fad..62687b9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
@@ -79,7 +79,7 @@ namespace Apache.Ignite.Core.Events
_isNear = r.ReadBoolean();
_eventNode = ReadNode(r);
_key = r.ReadObject<object>();
- _xid = IgniteGuid.Read(r);
+ _xid = r.ReadObject<IgniteGuid?>();
_newValue = r.ReadObject<object>();
_oldValue = r.ReadObject<object>();
_hasOldValue = r.ReadBoolean();
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
index 4992266..8aa446a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
@@ -58,9 +58,7 @@ namespace Apache.Ignite.Core.Events
/// <param name="r">The reader to read data from.</param>
protected EventBase(IBinaryRawReader r)
{
- var id = IgniteGuid.Read(r);
- Debug.Assert(id.HasValue);
- _id = id.Value;
+ _id = r.ReadObject<IgniteGuid>();
_localOrder = r.ReadLong();
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
index 06512c5..878562f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
@@ -54,8 +54,8 @@ namespace Apache.Ignite.Core.Events
{
_taskName = r.ReadString();
_taskClassName = r.ReadString();
- _taskSessionId = IgniteGuid.Read(r);
- _jobId = IgniteGuid.Read(r);
+ _taskSessionId = r.ReadObject<IgniteGuid?>();
+ _jobId = r.ReadObject<IgniteGuid?>();
_taskNode = ReadNode(r);
_taskSubjectId = r.ReadGuid();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
index aa03969..e2b9eaf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
@@ -50,7 +50,7 @@ namespace Apache.Ignite.Core.Events
{
_taskName = r.ReadString();
_taskClassName = r.ReadString();
- _taskSessionId = IgniteGuid.Read(r);
+ _taskSessionId = r.ReadObject<IgniteGuid?>();
_internal = r.ReadBoolean();
_subjectId = r.ReadGuid();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
index 2a59c06..092eb72 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
@@ -354,13 +354,13 @@ namespace Apache.Ignite.Core.Impl.Binary
/** <inheritdoc /> */
public Guid? ReadGuid(string fieldName)
{
- return ReadField(fieldName, BinaryUtils.ReadGuid, BinaryUtils.TypeGuid);
+ return ReadField<Guid?>(fieldName, r => BinaryUtils.ReadGuid(r), BinaryUtils.TypeGuid);
}
/** <inheritdoc /> */
public Guid? ReadGuid()
{
- return Read(BinaryUtils.ReadGuid, BinaryUtils.TypeGuid);
+ return Read<Guid?>(r => BinaryUtils.ReadGuid(r), BinaryUtils.TypeGuid);
}
/** <inheritdoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
index f601a34..beb2668 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
@@ -102,7 +102,7 @@ namespace Apache.Ignite.Core.Impl.Binary
ReadHandlers[BinaryUtils.TypeString] = new BinarySystemReader<string>(BinaryUtils.ReadString);
// 4. Guid.
- ReadHandlers[BinaryUtils.TypeGuid] = new BinarySystemReader<Guid?>(BinaryUtils.ReadGuid);
+ ReadHandlers[BinaryUtils.TypeGuid] = new BinarySystemReader<Guid?>(s => BinaryUtils.ReadGuid(s));
// 5. Primitive arrays.
ReadHandlers[BinaryUtils.TypeArrayBool] = new BinarySystemReader<bool[]>(BinaryUtils.ReadBooleanArray);
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
index 09c3ad4..f00b8f9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
@@ -190,6 +190,9 @@ namespace Apache.Ignite.Core.Impl.Binary
/** Type: platform object proxy. */
public const byte TypePlatformJavaObjectFactoryProxy = 99;
+ /** Type: platform object proxy. */
+ public const int TypeIgniteUuid = 2018070327;
+
/** Collection: custom. */
public const byte CollectionCustom = 0;
@@ -254,8 +257,8 @@ namespace Apache.Ignite.Core.Impl.Binary
? (Action<Guid, IBinaryStream>)WriteGuidFast : WriteGuidSlow;
/** Guid reader. */
- public static readonly Func<IBinaryStream, Guid?> ReadGuid = IsGuidSequential
- ? (Func<IBinaryStream, Guid?>)ReadGuidFast : ReadGuidSlow;
+ public static readonly Func<IBinaryStream, Guid> ReadGuid = IsGuidSequential
+ ? (Func<IBinaryStream, Guid>)ReadGuidFast : ReadGuidSlow;
/** String mode environment variable. */
public const string IgniteBinaryMarshallerUseStringSerializationVer2 =
@@ -1169,7 +1172,7 @@ namespace Apache.Ignite.Core.Impl.Binary
/// </summary>
/// <param name="stream">The stream.</param>
/// <returns>Guid.</returns>
- public static unsafe Guid? ReadGuidFast(IBinaryStream stream)
+ public static unsafe Guid ReadGuidFast(IBinaryStream stream)
{
JavaGuid jguid;
@@ -1187,7 +1190,7 @@ namespace Apache.Ignite.Core.Impl.Binary
/// </summary>
/// <param name="stream">The stream.</param>
/// <returns>Guid.</returns>
- public static unsafe Guid? ReadGuidSlow(IBinaryStream stream)
+ public static unsafe Guid ReadGuidSlow(IBinaryStream stream)
{
byte* jBytes = stackalloc byte[16];
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e5e3cbf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
index 6dee998..9ec4216 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -23,6 +23,7 @@ namespace Apache.Ignite.Core.Impl.Binary
using System.Linq;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache.Affinity;
+ using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Binary.IO;
using Apache.Ignite.Core.Impl.Binary.Metadata;
using Apache.Ignite.Core.Impl.Cache;
@@ -60,7 +61,7 @@ namespace Apache.Ignite.Core.Impl.Binary
/// <summary>
/// Constructor.
/// </summary>
- /// <param name="cfg">Configurtaion.</param>
+ /// <param name="cfg">Configuration.</param>
public Marshaller(BinaryConfiguration cfg)
{
// Validation.
@@ -609,6 +610,7 @@ namespace Apache.Ignite.Core.Impl.Binary
AddSystemType(0, r => new AffinityKey(r), "affKey");
AddSystemType(BinaryUtils.TypePlatformJavaObjectFactoryProxy, r => new PlatformJavaObjectFactoryProxy());
AddSystemType(0, r => new ObjectInfoHolder(r));
+ AddSystemType(BinaryUtils.TypeIgniteUuid, r => new IgniteGuid(r));
}
}
}
[07/16] ignite git commit: Merge remote-tracking branch
'origin/ignite-2.0' into ignite-2.0
Posted by vo...@apache.org.
Merge remote-tracking branch 'origin/ignite-2.0' into ignite-2.0
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/82f016fb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/82f016fb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/82f016fb
Branch: refs/heads/ignite-4565-ddl
Commit: 82f016fb9707a49eda27f9898bac96cf834e3ff5
Parents: e8e5236 4820c45
Author: devozerov <vo...@gridgain.com>
Authored: Thu Mar 16 14:50:18 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Thu Mar 16 14:50:18 2017 +0300
----------------------------------------------------------------------
.../platform/PlatformAbstractTarget.java | 8 ++
.../platform/PlatformAsyncResult.java | 41 +++++++++
.../platform/PlatformContextImpl.java | 10 +--
.../processors/platform/PlatformTarget.java | 10 +++
.../platform/PlatformTargetProxy.java | 9 ++
.../platform/PlatformTargetProxyImpl.java | 39 +++++++++
.../platform/PlatformComputeEchoTask.java | 6 ++
.../plugin/PlatformTestPluginTarget.java | 89 +++++++++++++++++++-
.../cpp/jni/include/ignite/jni/exports.h | 1 +
.../platforms/cpp/jni/include/ignite/jni/java.h | 2 +
modules/platforms/cpp/jni/project/vs/module.def | 1 +
modules/platforms/cpp/jni/src/exports.cpp | 4 +
modules/platforms/cpp/jni/src/java.cpp | 10 +++
.../Binary/BinaryReaderWriterTest.cs | 8 ++
.../Compute/ComputeApiTest.cs | 19 +++++
.../ConsoleRedirectTest.cs | 2 +-
.../Plugin/PluginTest.cs | 41 +++++++++
.../Apache.Ignite.Core/Common/IgniteGuid.cs | 47 +++++++----
.../Apache.Ignite.Core/Events/CacheEvent.cs | 2 +-
.../Apache.Ignite.Core/Events/EventBase.cs | 4 +-
.../Apache.Ignite.Core/Events/JobEvent.cs | 4 +-
.../Apache.Ignite.Core/Events/TaskEvent.cs | 2 +-
.../Impl/Binary/BinaryReader.cs | 4 +-
.../Impl/Binary/BinarySystemHandlers.cs | 2 +-
.../Impl/Binary/BinaryUtils.cs | 11 ++-
.../Impl/Binary/Marshaller.cs | 4 +-
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 29 +++++++
.../Impl/Plugin/PluginContext.cs | 9 ++
.../Impl/Unmanaged/IgniteJniNativeMethods.cs | 3 +
.../Impl/Unmanaged/UnmanagedUtils.cs | 5 ++
.../Interop/IPlatformTarget.cs | 13 +++
.../Apache.Ignite.Core/Plugin/IPluginContext.cs | 8 ++
32 files changed, 407 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
[16/16] ignite git commit: Merge branch 'ignite-2.0' into
ignite-4565-ddl
Posted by vo...@apache.org.
Merge branch 'ignite-2.0' into ignite-4565-ddl
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/70a11912
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/70a11912
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/70a11912
Branch: refs/heads/ignite-4565-ddl
Commit: 70a11912b34157a5e1b3275d3087052d133394b4
Parents: 636048f 9020d12
Author: devozerov <vo...@gridgain.com>
Authored: Fri Mar 17 17:49:40 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Fri Mar 17 17:49:40 2017 +0300
----------------------------------------------------------------------
.../ClientAbstractMultiNodeSelfTest.java | 13 +-
.../ignite/internal/IgniteTransactionsEx.java | 8 +-
.../processors/cache/GridCacheAdapter.java | 98 +-
.../processors/cache/GridCacheProxyImpl.java | 6 +-
.../cache/GridCacheSharedContext.java | 11 +-
.../processors/cache/GridCacheUtils.java | 6 +-
.../processors/cache/IgniteInternalCache.java | 5 +-
.../distributed/GridCacheCommittedTxInfo.java | 117 -
.../GridDistributedCacheAdapter.java | 2 +-
.../GridDistributedTxRemoteAdapter.java | 59 +-
.../dht/GridDhtPartitionTopologyImpl.java | 4 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 57 +-
.../cache/distributed/dht/GridDhtTxLocal.java | 126 +-
.../distributed/dht/GridDhtTxLocalAdapter.java | 28 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 65 +-
.../dht/colocated/GridDhtColocatedCache.java | 8 +-
.../colocated/GridDhtColocatedLockFuture.java | 7 +-
.../distributed/near/GridNearLockFuture.java | 4 +-
.../distributed/near/GridNearLockRequest.java | 200 +-
.../near/GridNearTransactionalCache.java | 6 +-
.../near/GridNearTxFinishFuture.java | 4 +-
.../cache/distributed/near/GridNearTxLocal.java | 2732 ++++++++++++++++-
.../near/GridNearTxPrepareFutureAdapter.java | 5 +-
.../near/GridNearTxPrepareRequest.java | 2 +-
.../distributed/near/GridNearTxRemote.java | 4 +-
.../store/GridCacheStoreManagerAdapter.java | 142 +-
.../cache/transactions/IgniteInternalTx.java | 80 +-
.../transactions/IgniteTransactionsImpl.java | 12 +-
.../cache/transactions/IgniteTxAdapter.java | 165 +-
.../cache/transactions/IgniteTxEntry.java | 4 +-
.../cache/transactions/IgniteTxHandler.java | 67 +-
.../IgniteTxImplicitSingleStateImpl.java | 4 +-
.../transactions/IgniteTxLocalAdapter.java | 2801 ++----------------
.../cache/transactions/IgniteTxLocalEx.java | 145 +-
.../cache/transactions/IgniteTxManager.java | 293 +-
.../cache/transactions/IgniteTxRemoteEx.java | 11 +
.../IgniteTxRemoteStateAdapter.java | 2 +-
.../cache/transactions/IgniteTxState.java | 2 +-
.../cache/transactions/IgniteTxStateImpl.java | 4 +-
.../transactions/TransactionProxyImpl.java | 13 +-
.../datastructures/DataStructuresProcessor.java | 32 +-
.../datastructures/GridCacheAtomicLongImpl.java | 18 +-
.../GridCacheAtomicReferenceImpl.java | 6 +-
.../GridCacheAtomicSequenceImpl.java | 4 +-
.../GridCacheAtomicStampedImpl.java | 6 +-
.../GridCacheCountDownLatchImpl.java | 6 +-
.../datastructures/GridCacheLockImpl.java | 11 +-
.../datastructures/GridCacheSemaphoreImpl.java | 18 +-
.../GridTransactionalCacheQueueImpl.java | 10 +-
.../processors/igfs/IgfsDataManager.java | 55 +-
.../processors/igfs/IgfsMetaManager.java | 73 +-
.../platform/PlatformAbstractTarget.java | 8 +
.../platform/PlatformAsyncResult.java | 41 +
.../platform/PlatformContextImpl.java | 10 +-
.../processors/platform/PlatformTarget.java | 10 +
.../platform/PlatformTargetProxy.java | 9 +
.../platform/PlatformTargetProxyImpl.java | 39 +
.../service/GridServiceProcessor.java | 6 +-
.../internal/TestRecordingCommunicationSpi.java | 29 +
.../processors/cache/GridCacheTestStore.java | 2 -
.../cache/IgniteTxConfigCacheSelfTest.java | 4 +-
.../IgniteCacheSystemTransactionsSelfTest.java | 7 +-
.../IgniteTxCachePrimarySyncTest.java | 5 +
...xOriginatingNodeFailureAbstractSelfTest.java | 6 +-
...cOriginatingNodeFailureAbstractSelfTest.java | 4 +-
...ePrimaryNodeFailureRecoveryAbstractTest.java | 9 +-
.../dht/IgniteCacheTxRecoveryRollbackTest.java | 501 ++++
.../GridCachePartitionedTxSalvageSelfTest.java | 7 +-
.../TxOptimisticDeadlockDetectionTest.java | 30 +-
...lockMessageSystemPoolStarvationSelfTest.java | 6 +-
.../platform/PlatformComputeEchoTask.java | 6 +
.../plugin/PlatformTestPluginTarget.java | 89 +-
.../IgniteCacheRestartTestSuite2.java | 3 +-
.../IgniteCacheTxRecoverySelfTestSuite.java | 3 +
.../apache/ignite/util/GridRandomSelfTest.java | 17 -
.../HibernateReadWriteAccessStrategy.java | 12 +-
.../processors/cache/jta/CacheJtaManager.java | 3 +-
.../processors/cache/jta/CacheJtaResource.java | 8 +-
.../cpp/jni/include/ignite/jni/exports.h | 1 +
.../platforms/cpp/jni/include/ignite/jni/java.h | 2 +
modules/platforms/cpp/jni/project/vs/module.def | 1 +
modules/platforms/cpp/jni/src/exports.cpp | 4 +
modules/platforms/cpp/jni/src/java.cpp | 10 +
.../Binary/BinaryReaderWriterTest.cs | 8 +
.../Compute/ComputeApiTest.cs | 19 +
.../ConsoleRedirectTest.cs | 2 +-
.../Plugin/PluginTest.cs | 41 +
.../Apache.Ignite.Core/Common/IgniteGuid.cs | 47 +-
.../Apache.Ignite.Core/Events/CacheEvent.cs | 2 +-
.../Apache.Ignite.Core/Events/EventBase.cs | 4 +-
.../Apache.Ignite.Core/Events/JobEvent.cs | 4 +-
.../Apache.Ignite.Core/Events/TaskEvent.cs | 2 +-
.../Impl/Binary/BinaryReader.cs | 4 +-
.../Impl/Binary/BinarySystemHandlers.cs | 2 +-
.../Impl/Binary/BinaryUtils.cs | 11 +-
.../Impl/Binary/Marshaller.cs | 4 +-
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 29 +
.../Impl/Plugin/PluginContext.cs | 9 +
.../Impl/Unmanaged/IgniteJniNativeMethods.cs | 3 +
.../Impl/Unmanaged/UnmanagedUtils.cs | 5 +
.../Interop/IPlatformTarget.cs | 13 +
.../Apache.Ignite.Core/Plugin/IPluginContext.cs | 8 +
102 files changed, 4557 insertions(+), 4113 deletions(-)
----------------------------------------------------------------------
[14/16] ignite git commit: Internal cache API cleanup.
Posted by vo...@apache.org.
Internal cache API cleanup.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/decb0c7a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/decb0c7a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/decb0c7a
Branch: refs/heads/ignite-4565-ddl
Commit: decb0c7aa62f9354b25ee0a09ca19b424a688e8b
Parents: 82f016f
Author: sboikov <sb...@gridgain.com>
Authored: Thu Mar 16 18:25:36 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Mar 16 18:25:36 2017 +0300
----------------------------------------------------------------------
.../ClientAbstractMultiNodeSelfTest.java | 13 +-
.../ignite/internal/IgniteTransactionsEx.java | 8 +-
.../processors/cache/GridCacheAdapter.java | 98 +-
.../processors/cache/GridCacheProxyImpl.java | 6 +-
.../cache/GridCacheSharedContext.java | 11 +-
.../processors/cache/GridCacheUtils.java | 6 +-
.../processors/cache/IgniteInternalCache.java | 5 +-
.../distributed/GridCacheCommittedTxInfo.java | 117 -
.../GridDistributedCacheAdapter.java | 2 +-
.../GridDistributedTxRemoteAdapter.java | 59 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 57 +-
.../cache/distributed/dht/GridDhtTxLocal.java | 126 +-
.../distributed/dht/GridDhtTxLocalAdapter.java | 28 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 65 +-
.../dht/colocated/GridDhtColocatedCache.java | 8 +-
.../colocated/GridDhtColocatedLockFuture.java | 7 +-
.../distributed/near/GridNearLockFuture.java | 4 +-
.../distributed/near/GridNearLockRequest.java | 200 +-
.../near/GridNearTransactionalCache.java | 6 +-
.../near/GridNearTxFinishFuture.java | 4 +-
.../cache/distributed/near/GridNearTxLocal.java | 2732 ++++++++++++++++-
.../near/GridNearTxPrepareFutureAdapter.java | 5 +-
.../near/GridNearTxPrepareRequest.java | 2 +-
.../distributed/near/GridNearTxRemote.java | 4 +-
.../store/GridCacheStoreManagerAdapter.java | 142 +-
.../cache/transactions/IgniteInternalTx.java | 80 +-
.../transactions/IgniteTransactionsImpl.java | 12 +-
.../cache/transactions/IgniteTxAdapter.java | 165 +-
.../cache/transactions/IgniteTxEntry.java | 4 +-
.../cache/transactions/IgniteTxHandler.java | 67 +-
.../IgniteTxImplicitSingleStateImpl.java | 4 +-
.../transactions/IgniteTxLocalAdapter.java | 2801 ++----------------
.../cache/transactions/IgniteTxLocalEx.java | 145 +-
.../cache/transactions/IgniteTxManager.java | 293 +-
.../cache/transactions/IgniteTxRemoteEx.java | 11 +
.../IgniteTxRemoteStateAdapter.java | 2 +-
.../cache/transactions/IgniteTxState.java | 2 +-
.../cache/transactions/IgniteTxStateImpl.java | 4 +-
.../transactions/TransactionProxyImpl.java | 13 +-
.../datastructures/DataStructuresProcessor.java | 32 +-
.../datastructures/GridCacheAtomicLongImpl.java | 18 +-
.../GridCacheAtomicReferenceImpl.java | 6 +-
.../GridCacheAtomicSequenceImpl.java | 4 +-
.../GridCacheAtomicStampedImpl.java | 6 +-
.../GridCacheCountDownLatchImpl.java | 6 +-
.../datastructures/GridCacheLockImpl.java | 11 +-
.../datastructures/GridCacheSemaphoreImpl.java | 18 +-
.../GridTransactionalCacheQueueImpl.java | 10 +-
.../processors/igfs/IgfsDataManager.java | 55 +-
.../processors/igfs/IgfsMetaManager.java | 73 +-
.../service/GridServiceProcessor.java | 6 +-
.../internal/TestRecordingCommunicationSpi.java | 29 +
.../processors/cache/GridCacheTestStore.java | 2 -
.../cache/IgniteTxConfigCacheSelfTest.java | 4 +-
.../IgniteCacheSystemTransactionsSelfTest.java | 7 +-
.../IgniteTxCachePrimarySyncTest.java | 5 +
...xOriginatingNodeFailureAbstractSelfTest.java | 6 +-
...cOriginatingNodeFailureAbstractSelfTest.java | 4 +-
...ePrimaryNodeFailureRecoveryAbstractTest.java | 9 +-
.../dht/IgniteCacheTxRecoveryRollbackTest.java | 501 ++++
.../GridCachePartitionedTxSalvageSelfTest.java | 7 +-
.../TxOptimisticDeadlockDetectionTest.java | 30 +-
...lockMessageSystemPoolStarvationSelfTest.java | 6 +-
.../IgniteCacheRestartTestSuite2.java | 3 +-
.../IgniteCacheTxRecoverySelfTestSuite.java | 3 +
.../HibernateReadWriteAccessStrategy.java | 12 +-
.../processors/cache/jta/CacheJtaManager.java | 3 +-
.../processors/cache/jta/CacheJtaResource.java | 8 +-
68 files changed, 4148 insertions(+), 4054 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java
index 7fb2385..2fba49a 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java
@@ -56,6 +56,7 @@ import org.apache.ignite.internal.managers.communication.GridIoMessage;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockRequest;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionable;
@@ -480,11 +481,11 @@ public abstract class ClientAbstractMultiNodeSelfTest extends GridCommonAbstract
@SuppressWarnings("unchecked")
private static class TestCommunicationSpi extends TcpCommunicationSpi {
/** {@inheritDoc} */
- @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackClosure)
+ @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC)
throws IgniteSpiException {
checkSyncFlags((GridIoMessage)msg);
- super.sendMessage(node, msg, ackClosure);
+ super.sendMessage(node, msg, ackC);
}
/**
@@ -512,13 +513,13 @@ public abstract class ClientAbstractMultiNodeSelfTest extends GridCommonAbstract
IgniteInternalTx t = tm.tx(v);
if (t.hasWriteKey(cacheCtx.txKey(cacheCtx.toCacheKeyObject("x1"))))
- assertEquals("Invalid tx flags: " + t, FULL_ASYNC, t.syncMode());
+ assertEquals("Invalid tx flags: " + t, FULL_ASYNC, ((IgniteTxLocalAdapter)t).syncMode());
else if (t.hasWriteKey(cacheCtx.txKey(cacheCtx.toCacheKeyObject("x2"))))
- assertEquals("Invalid tx flags: " + t, FULL_SYNC, t.syncMode());
+ assertEquals("Invalid tx flags: " + t, FULL_SYNC, ((IgniteTxLocalAdapter)t).syncMode());
else if (t.hasWriteKey(cacheCtx.txKey(cacheCtx.toCacheKeyObject("x3"))))
- assertEquals("Invalid tx flags: " + t, FULL_ASYNC, t.syncMode());
+ assertEquals("Invalid tx flags: " + t, FULL_ASYNC, ((IgniteTxLocalAdapter)t).syncMode());
else if (t.hasWriteKey(cacheCtx.txKey(cacheCtx.toCacheKeyObject("x4"))))
- assertEquals("Invalid tx flags: " + t, FULL_SYNC, t.syncMode());
+ assertEquals("Invalid tx flags: " + t, FULL_SYNC, ((IgniteTxLocalAdapter)t).syncMode());
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/IgniteTransactionsEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteTransactionsEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteTransactionsEx.java
index 9772dcc..4133ddc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteTransactionsEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteTransactionsEx.java
@@ -19,7 +19,7 @@ package org.apache.ignite.internal;
import org.apache.ignite.IgniteTransactions;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;
@@ -35,7 +35,7 @@ public interface IgniteTransactionsEx extends IgniteTransactions {
* @param txSize Number of entries participating in transaction (may be approximate).
* @return New transaction.
*/
- public IgniteInternalTx txStartEx(GridCacheContext ctx,
+ public GridNearTxLocal txStartEx(GridCacheContext ctx,
TransactionConcurrency concurrency,
TransactionIsolation isolation,
long timeout,
@@ -47,5 +47,7 @@ public interface IgniteTransactionsEx extends IgniteTransactions {
* @param isolation Isolation.
* @return New transaction.
*/
- public IgniteInternalTx txStartEx(GridCacheContext ctx, TransactionConcurrency concurrency, TransactionIsolation isolation);
+ public GridNearTxLocal txStartEx(GridCacheContext ctx,
+ TransactionConcurrency concurrency,
+ TransactionIsolation isolation);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 71be718..3bfd1f8 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
@@ -86,18 +86,16 @@ import org.apache.ignite.internal.processors.cache.distributed.IgniteExternaliza
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
-import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
import org.apache.ignite.internal.processors.cache.version.GridCacheRawVersionedEntry;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerEntry;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl;
import org.apache.ignite.internal.processors.dr.IgniteDrDataStreamerCacheUpdater;
-import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.processors.platform.cache.PlatformCacheEntryFilter;
import org.apache.ignite.internal.processors.task.GridInternal;
import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
@@ -1876,7 +1874,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
if (F.isEmpty(keys))
return new GridFinishedFuture<>(Collections.<K1, V1>emptyMap());
- IgniteTxLocalAdapter tx = null;
+ GridNearTxLocal tx = null;
if (checkTx) {
try {
@@ -2132,7 +2130,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
else {
return asyncOp(tx, new AsyncOp<Map<K1, V1>>(keys) {
- @Override public IgniteInternalFuture<Map<K1, V1>> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture<Map<K1, V1>> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
return tx.getAllAsync(ctx,
readyTopVer,
keys,
@@ -2187,7 +2185,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
protected V getAndPut0(final K key, final V val, @Nullable final CacheEntryPredicate filter)
throws IgniteCheckedException {
return syncOp(new SyncOp<V>(true) {
- @Override public V op(IgniteTxLocalAdapter tx) throws IgniteCheckedException {
+ @Override public V op(GridNearTxLocal tx) throws IgniteCheckedException {
return (V)tx.putAsync(ctx, null, key, val, true, filter).get().value();
}
@@ -2237,7 +2235,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
@Nullable final CacheEntryPredicate filter)
{
return asyncOp(new AsyncOp<V>() {
- @Override public IgniteInternalFuture<V> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture<V> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
return tx.putAsync(ctx, readyTopVer, key, val, true, filter)
.chain((IgniteClosure<IgniteInternalFuture<GridCacheReturn>, V>)RET2VAL);
}
@@ -2293,7 +2291,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
protected boolean put0(final K key, final V val, final CacheEntryPredicate filter)
throws IgniteCheckedException {
Boolean res = syncOp(new SyncOp<Boolean>(true) {
- @Override public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException {
+ @Override public Boolean op(GridNearTxLocal tx) throws IgniteCheckedException {
return tx.putAsync(ctx, null, key, val, false, filter).get().success();
}
@@ -2316,7 +2314,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
ctx.dr().onReceiveCacheEntriesReceived(drMap.size());
syncOp(new SyncInOp(drMap.size() == 1) {
- @Override public void inOp(IgniteTxLocalAdapter tx) throws IgniteCheckedException {
+ @Override public void inOp(GridNearTxLocal tx) throws IgniteCheckedException {
tx.putAllDrAsync(ctx, drMap).get();
}
@@ -2335,7 +2333,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
ctx.dr().onReceiveCacheEntriesReceived(drMap.size());
return asyncOp(new AsyncOp(drMap.keySet()) {
- @Override public IgniteInternalFuture op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
return tx.putAllDrAsync(ctx, drMap);
}
@@ -2380,7 +2378,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
validateCacheKey(key);
return syncOp(new SyncOp<EntryProcessorResult<T>>(true) {
- @Nullable @Override public EntryProcessorResult<T> op(IgniteTxLocalAdapter tx)
+ @Nullable @Override public EntryProcessorResult<T> op(GridNearTxLocal tx)
throws IgniteCheckedException {
assert topVer == null || tx.implicit();
@@ -2418,7 +2416,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
validateCacheKeys(keys);
return syncOp(new SyncOp<Map<K, EntryProcessorResult<T>>>(keys.size() == 1) {
- @Nullable @Override public Map<K, EntryProcessorResult<T>> op(IgniteTxLocalAdapter tx)
+ @Nullable @Override public Map<K, EntryProcessorResult<T>> op(GridNearTxLocal tx)
throws IgniteCheckedException {
Map<? extends K, EntryProcessor<K, V, Object>> invokeMap = F.viewAsMap(keys,
new C1<K, EntryProcessor<K, V, Object>>() {
@@ -2448,7 +2446,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
validateCacheKey(key);
IgniteInternalFuture<?> fut = asyncOp(new AsyncOp() {
- @Override public IgniteInternalFuture op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
Map<? extends K, EntryProcessor<K, V, Object>> invokeMap =
Collections.singletonMap(key, (EntryProcessor<K, V, Object>)entryProcessor);
@@ -2491,7 +2489,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
validateCacheKeys(keys);
IgniteInternalFuture<?> fut = asyncOp(new AsyncOp(keys) {
- @Override public IgniteInternalFuture<GridCacheReturn> op(IgniteTxLocalAdapter tx,
+ @Override public IgniteInternalFuture<GridCacheReturn> op(GridNearTxLocal tx,
AffinityTopologyVersion readyTopVer) {
Map<? extends K, EntryProcessor<K, V, Object>> invokeMap = F.viewAsMap(keys, new C1<K, EntryProcessor<K, V, Object>>() {
@Override public EntryProcessor apply(K k) {
@@ -2532,7 +2530,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
validateCacheKeys(map.keySet());
IgniteInternalFuture<?> fut = asyncOp(new AsyncOp(map.keySet()) {
- @Override public IgniteInternalFuture<GridCacheReturn> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture<GridCacheReturn> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
return tx.invokeAsync(ctx,
readyTopVer,
(Map<? extends K, ? extends EntryProcessor<K, V, Object>>)map,
@@ -2568,7 +2566,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
validateCacheKeys(map.keySet());
return syncOp(new SyncOp<Map<K, EntryProcessorResult<T>>>(map.size() == 1) {
- @Nullable @Override public Map<K, EntryProcessorResult<T>> op(IgniteTxLocalAdapter tx)
+ @Nullable @Override public Map<K, EntryProcessorResult<T>> op(GridNearTxLocal tx)
throws IgniteCheckedException {
IgniteInternalFuture<GridCacheReturn> fut =
tx.invokeAsync(ctx, null, (Map<? extends K, ? extends EntryProcessor<K, V, Object>>)map, args);
@@ -2616,7 +2614,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
public IgniteInternalFuture<Boolean> putAsync0(final K key, final V val,
@Nullable final CacheEntryPredicate filter) {
return asyncOp(new AsyncOp<Boolean>() {
- @Override public IgniteInternalFuture<Boolean> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture<Boolean> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
return tx.putAsync(ctx,
readyTopVer,
key,
@@ -2721,7 +2719,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
*/
protected void putAll0(final Map<? extends K, ? extends V> m) throws IgniteCheckedException {
syncOp(new SyncInOp(m.size() == 1) {
- @Override public void inOp(IgniteTxLocalAdapter tx) throws IgniteCheckedException {
+ @Override public void inOp(GridNearTxLocal tx) throws IgniteCheckedException {
tx.putAllAsync(ctx, null, m, false).get();
}
@@ -2748,7 +2746,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
*/
protected IgniteInternalFuture<?> putAllAsync0(final Map<? extends K, ? extends V> m) {
return asyncOp(new AsyncOp(m.keySet()) {
- @Override public IgniteInternalFuture<?> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture<?> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
return tx.putAllAsync(ctx,
readyTopVer,
m,
@@ -2789,7 +2787,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
final boolean keepBinary = ctx.keepBinary();
return syncOp(new SyncOp<V>(true) {
- @Override public V op(IgniteTxLocalAdapter tx) throws IgniteCheckedException {
+ @Override public V op(GridNearTxLocal tx) throws IgniteCheckedException {
K key0 = keepBinary ? (K) ctx.toCacheKeyObject(key) : key;
V ret = tx.removeAllAsync(ctx,
@@ -2839,7 +2837,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
*/
protected IgniteInternalFuture<V> getAndRemoveAsync0(final K key) {
return asyncOp(new AsyncOp<V>() {
- @Override public IgniteInternalFuture<V> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture<V> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
// TODO should we invoke interceptor here?
return tx.removeAllAsync(ctx,
readyTopVer,
@@ -2897,7 +2895,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
*/
protected void removeAll0(final Collection<? extends K> keys) throws IgniteCheckedException {
syncOp(new SyncInOp(keys.size() == 1) {
- @Override public void inOp(IgniteTxLocalAdapter tx) throws IgniteCheckedException {
+ @Override public void inOp(GridNearTxLocal tx) throws IgniteCheckedException {
tx.removeAllAsync(ctx,
null,
keys,
@@ -2938,7 +2936,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
*/
protected IgniteInternalFuture<Object> removeAllAsync0(final Collection<? extends K> keys) {
return asyncOp(new AsyncOp(keys) {
- @Override public IgniteInternalFuture<?> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture<?> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
return tx.removeAllAsync(ctx,
readyTopVer,
keys,
@@ -2990,7 +2988,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
*/
protected boolean remove0(final K key, final CacheEntryPredicate filter) throws IgniteCheckedException {
Boolean res = syncOp(new SyncOp<Boolean>(true) {
- @Override public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException {
+ @Override public Boolean op(GridNearTxLocal tx) throws IgniteCheckedException {
return tx.removeAllAsync(ctx,
null,
Collections.singletonList(key),
@@ -3046,7 +3044,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
*/
protected IgniteInternalFuture<Boolean> removeAsync0(final K key, @Nullable final CacheEntryPredicate filter) {
return asyncOp(new AsyncOp<Boolean>() {
- @Override public IgniteInternalFuture<Boolean> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture<Boolean> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
return tx.removeAllAsync(ctx,
readyTopVer,
Collections.singletonList(key),
@@ -3071,8 +3069,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
ctx.dr().onReceiveCacheEntriesReceived(drMap.size());
syncOp(new SyncInOp(false) {
- @Override public void inOp(IgniteTxLocalAdapter tx) throws IgniteCheckedException {
- tx.removeAllDrAsync(ctx, (Map)drMap).get();
+ @Override public void inOp(GridNearTxLocal tx) throws IgniteCheckedException {
+ tx.removeAllDrAsync(ctx, drMap).get();
}
@Override public String toString() {
@@ -3090,8 +3088,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
ctx.dr().onReceiveCacheEntriesReceived(drMap.size());
return asyncOp(new AsyncOp(drMap.keySet()) {
- @Override public IgniteInternalFuture<?> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
- return tx.removeAllDrAsync(ctx, (Map)drMap);
+ @Override public IgniteInternalFuture<?> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
+ return tx.removeAllDrAsync(ctx, drMap);
}
@Override public String toString() {
@@ -3160,10 +3158,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
/** {@inheritDoc} */
- @Nullable @Override public Transaction tx() {
- IgniteTxAdapter tx = ctx.tm().threadLocalTx(ctx);
-
- return tx == null ? null : new TransactionProxyImpl<>(tx, ctx.shared(), false);
+ @Nullable @Override public GridNearTxLocal tx() {
+ return ctx.tm().threadLocalTx(ctx);
}
/** {@inheritDoc} */
@@ -3291,7 +3287,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
/** {@inheritDoc} */
- @Override public IgniteInternalTx txStartEx(TransactionConcurrency concurrency, TransactionIsolation isolation) {
+ @Override public GridNearTxLocal txStartEx(TransactionConcurrency concurrency, TransactionIsolation isolation) {
IgniteTransactionsEx txs = ctx.kernalContext().cache().transactions();
return txs.txStartEx(ctx, concurrency, isolation);
@@ -4142,7 +4138,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @return Transaction commit future.
*/
@SuppressWarnings("unchecked")
- public IgniteInternalFuture<IgniteInternalTx> commitTxAsync(final IgniteInternalTx tx) {
+ IgniteInternalFuture<IgniteInternalTx> commitTxAsync(final GridNearTxLocal tx) {
FutureHolder holder = lastFut.get();
holder.lock();
@@ -4154,7 +4150,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
IgniteInternalFuture<IgniteInternalTx> f = new GridEmbeddedFuture<>(fut,
new C2<Object, Exception, IgniteInternalFuture<IgniteInternalTx>>() {
@Override public IgniteInternalFuture<IgniteInternalTx> apply(Object o, Exception e) {
- return tx.commitAsync();
+ return tx.commitNearTxLocalAsync();
}
});
@@ -4163,7 +4159,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
return f;
}
- IgniteInternalFuture<IgniteInternalTx> f = tx.commitAsync();
+ IgniteInternalFuture<IgniteInternalTx> f = tx.commitNearTxLocalAsync();
saveFuture(holder, f);
@@ -4208,7 +4204,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
awaitLastFut();
- IgniteTxLocalAdapter tx = ctx.tm().threadLocalTx(ctx);
+ GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx);
if (tx == null || tx.implicit()) {
TransactionConfiguration tCfg = CU.transactionConfiguration(ctx, ctx.kernalContext().config());
@@ -4304,7 +4300,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
if (log.isDebugEnabled())
log.debug("Performing async op: " + op);
- IgniteTxLocalAdapter tx = ctx.tm().threadLocalTx(ctx);
+ GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx);
CacheOperationContext opCtx = ctx.operationContextPerCall();
@@ -4348,7 +4344,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
*/
@SuppressWarnings("unchecked")
protected <T> IgniteInternalFuture<T> asyncOp(
- IgniteTxLocalAdapter tx,
+ GridNearTxLocal tx,
final AsyncOp<T> op,
final CacheOperationContext opCtx
) {
@@ -4364,7 +4360,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
try {
IgniteInternalFuture fut = holder.future();
- final IgniteTxLocalAdapter tx0 = tx;
+ final GridNearTxLocal tx0 = tx;
if (fut != null && !fut.isDone()) {
IgniteInternalFuture<T> f = new GridEmbeddedFuture(fut,
@@ -4383,7 +4379,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
throw e;
}
catch (IgniteCheckedException e1) {
- tx0.rollbackAsync();
+ tx0.rollbackNearTxLocalAsync();
throw e1;
}
@@ -4409,7 +4405,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
throw e;
}
catch (IgniteCheckedException e1) {
- tx0.rollbackAsync();
+ tx0.rollbackNearTxLocalAsync();
throw e1;
}
@@ -4925,7 +4921,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
private int retries;
/** */
- private IgniteTxLocalAdapter tx;
+ private GridNearTxLocal tx;
/** */
private CacheOperationContext opCtx;
@@ -5173,7 +5169,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @return Operation return value.
* @throws IgniteCheckedException If failed.
*/
- @Nullable public abstract T op(IgniteTxLocalAdapter tx) throws IgniteCheckedException;
+ @Nullable public abstract T op(GridNearTxLocal tx) throws IgniteCheckedException;
}
/**
@@ -5188,7 +5184,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
/** {@inheritDoc} */
- @Nullable @Override public final Object op(IgniteTxLocalAdapter tx) throws IgniteCheckedException {
+ @Nullable @Override public final Object op(GridNearTxLocal tx) throws IgniteCheckedException {
inOp(tx);
return null;
@@ -5198,7 +5194,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @param tx Transaction.
* @throws IgniteCheckedException If failed.
*/
- public abstract void inOp(IgniteTxLocalAdapter tx) throws IgniteCheckedException;
+ public abstract void inOp(GridNearTxLocal tx) throws IgniteCheckedException;
}
/**
@@ -5234,14 +5230,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @param readyTopVer Ready topology version.
* @return Operation future.
*/
- public abstract IgniteInternalFuture<T> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer);
+ public abstract IgniteInternalFuture<T> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer);
/**
* @param tx Transaction.
* @param opCtx Operation context.
* @return Operation future.
*/
- public IgniteInternalFuture<T> op(final IgniteTxLocalAdapter tx, CacheOperationContext opCtx) {
+ public IgniteInternalFuture<T> op(final GridNearTxLocal tx, CacheOperationContext opCtx) {
AffinityTopologyVersion txTopVer = tx.topologyVersionSnapshot();
if (txTopVer != null)
@@ -5267,7 +5263,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
*/
private IgniteInternalFuture<T> waitTopologyFuture(IgniteInternalFuture<?> topFut,
final AffinityTopologyVersion topVer,
- final IgniteTxLocalAdapter tx,
+ final GridNearTxLocal tx,
final CacheOperationContext opCtx) {
final GridFutureAdapter fut0 = new GridFutureAdapter();
@@ -5304,7 +5300,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @param opCtx Operation context.
* @return Future.
*/
- private IgniteInternalFuture<T> runOp(IgniteTxLocalAdapter tx,
+ private IgniteInternalFuture<T> runOp(GridNearTxLocal tx,
AffinityTopologyVersion topVer,
CacheOperationContext opCtx) {
ctx.operationContextPerCall(opCtx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index 00898ec..787a767 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -40,8 +40,8 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.affinity.GridCacheAffinityProxy;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -939,7 +939,7 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
}
/** {@inheritDoc} */
- @Override public IgniteInternalTx txStartEx(TransactionConcurrency concurrency, TransactionIsolation isolation) {
+ @Override public GridNearTxLocal txStartEx(TransactionConcurrency concurrency, TransactionIsolation isolation) {
CacheOperationContext prev = gate.enter(opCtx);
try {
@@ -977,7 +977,7 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
}
/** {@inheritDoc} */
- @Override public Transaction tx() {
+ @Override public GridNearTxLocal tx() {
CacheOperationContext prev = gate.enter(opCtx);
try {
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
index 0f79100..39a3baa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
@@ -39,6 +39,7 @@ import org.apache.ignite.internal.managers.deployment.GridDeploymentManager;
import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.jta.CacheJtaManagerAdapter;
import org.apache.ignite.internal.processors.cache.store.CacheStoreManager;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
@@ -731,7 +732,7 @@ public class GridCacheSharedContext<K, V> {
* @param tx Transaction to close.
* @throws IgniteCheckedException If failed.
*/
- public void endTx(IgniteInternalTx tx) throws IgniteCheckedException {
+ public void endTx(GridNearTxLocal tx) throws IgniteCheckedException {
tx.txState().awaitLastFut(this);
tx.close();
@@ -742,13 +743,13 @@ public class GridCacheSharedContext<K, V> {
* @return Commit future.
*/
@SuppressWarnings("unchecked")
- public IgniteInternalFuture<IgniteInternalTx> commitTxAsync(IgniteInternalTx tx) {
+ public IgniteInternalFuture<IgniteInternalTx> commitTxAsync(GridNearTxLocal tx) {
GridCacheContext ctx = tx.txState().singleCacheContext(this);
if (ctx == null) {
tx.txState().awaitLastFut(this);
- return tx.commitAsync();
+ return tx.commitNearTxLocalAsync();
}
else
return ctx.cache().commitTxAsync(tx);
@@ -759,10 +760,10 @@ public class GridCacheSharedContext<K, V> {
* @throws IgniteCheckedException If failed.
* @return Rollback future.
*/
- public IgniteInternalFuture rollbackTxAsync(IgniteInternalTx tx) throws IgniteCheckedException {
+ public IgniteInternalFuture rollbackTxAsync(GridNearTxLocal tx) throws IgniteCheckedException {
tx.txState().awaitLastFut(this);
- return tx.rollbackAsync();
+ return tx.rollbackNearTxLocalAsync();
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 3e68b70..7131612 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -64,6 +64,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockCancelledException;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -97,7 +98,6 @@ import org.jsr166.ConcurrentHashMap8;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.LOCAL;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
@@ -891,7 +891,7 @@ public class GridCacheUtils {
* @param isolation Isolation.
* @return New transaction.
*/
- public static IgniteInternalTx txStartInternal(GridCacheContext ctx, IgniteInternalCache prj,
+ public static GridNearTxLocal txStartInternal(GridCacheContext ctx, IgniteInternalCache prj,
TransactionConcurrency concurrency, TransactionIsolation isolation) {
assert ctx != null;
assert prj != null;
@@ -1257,7 +1257,7 @@ public class GridCacheUtils {
public static <K, V> void inTx(IgniteInternalCache<K, V> cache, TransactionConcurrency concurrency,
TransactionIsolation isolation, IgniteInClosureX<IgniteInternalCache<K ,V>> clo) throws IgniteCheckedException {
- try (IgniteInternalTx tx = cache.txStartEx(concurrency, isolation);) {
+ try (GridNearTxLocal tx = cache.txStartEx(concurrency, isolation);) {
clo.applyx(cache);
tx.commit();
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
index 0ac98fb..5471335 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
@@ -43,6 +43,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -952,7 +953,7 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
* @param isolation Isolation.
* @return New transaction.
*/
- public IgniteInternalTx txStartEx(TransactionConcurrency concurrency, TransactionIsolation isolation);
+ public GridNearTxLocal txStartEx(TransactionConcurrency concurrency, TransactionIsolation isolation);
/**
* Starts transaction with specified isolation, concurrency, timeout, invalidation flag,
@@ -976,7 +977,7 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
* @return Transaction started by this thread or {@code null} if this thread
* does not have a transaction.
*/
- @Nullable public Transaction tx();
+ @Nullable public GridNearTxLocal tx();
/**
* Evicts entry associated with given key from cache. Note, that entry will be evicted
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheCommittedTxInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheCommittedTxInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheCommittedTxInfo.java
deleted file mode 100644
index 875ada0..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheCommittedTxInfo.java
+++ /dev/null
@@ -1,117 +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 java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.UUID;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-
-/**
- * Committed transaction information. Contains recovery writes that will be used to set commit values
- * in case if originating node crashes.
- */
-@Deprecated
-public class GridCacheCommittedTxInfo implements Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Originating transaction ID. */
- private GridCacheVersion originatingTxId;
-
- /** Originating node ID. */
- private UUID originatingNodeId;
-
- /** Recovery writes, i.e. values that have never been sent to remote nodes. */
- @GridToStringInclude
- private Collection<IgniteTxEntry> recoveryWrites;
-
- /**
- * Empty constructor required by {@link Externalizable}.
- */
- public GridCacheCommittedTxInfo() {
- // No-op.
- }
-
- /**
- * @param tx Committed cache transaction.
- */
- public GridCacheCommittedTxInfo(IgniteInternalTx tx) {
- assert !tx.local() || !tx.replicated();
-
- originatingTxId = tx.nearXidVersion();
- originatingNodeId = tx.eventNodeId();
- }
-
- /**
- * @return Originating transaction ID (the transaction ID for replicated cache and near transaction ID
- * for partitioned cache).
- */
- public GridCacheVersion originatingTxId() {
- return originatingTxId;
- }
-
- /**
- * @return Originating node ID (the local transaction node ID for replicated cache and near node ID
- * for partitioned cache).
- */
- public UUID originatingNodeId() {
- return originatingNodeId;
- }
-
- /**
- * @return Collection of recovery writes.
- */
- public Collection<IgniteTxEntry> recoveryWrites() {
- return recoveryWrites == null ? Collections.<IgniteTxEntry>emptyList() : recoveryWrites;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- originatingTxId.writeExternal(out);
-
- U.writeUuid(out, originatingNodeId);
-
- U.writeCollection(out, recoveryWrites);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- originatingTxId = new GridCacheVersion();
-
- originatingTxId.readExternal(in);
-
- originatingNodeId = U.readUuid(in);
-
- recoveryWrites = U.readCollection(in);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridCacheCommittedTxInfo.class, this, "recoveryWrites", recoveryWrites);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 7e4deff..00bc6d7 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
@@ -111,7 +111,7 @@ public abstract class GridDistributedCacheAdapter<K, V> extends GridCacheAdapter
/** {@inheritDoc} */
@Override public IgniteInternalFuture<Boolean> lockAllAsync(Collection<? extends K> keys, long timeout) {
- IgniteTxLocalEx tx = ctx.tm().userTxx();
+ IgniteTxLocalEx tx = ctx.tm().userTx();
// Return value flag is true because we choose to bring values for explicit locks.
return lockAllAsync(ctx.cacheKeysView(keys),
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 68c0e57..b31a7be 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
@@ -83,7 +83,7 @@ import static org.apache.ignite.transactions.TransactionState.UNKNOWN;
/**
* Transaction created by system implicitly on remote nodes.
*/
-public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
+public abstract class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
implements IgniteTxRemoteEx {
/** */
private static final long serialVersionUID = 0L;
@@ -180,11 +180,6 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
}
/** {@inheritDoc} */
- @Override public Collection<UUID> masterNodeIds() {
- return Collections.singleton(nodeId);
- }
-
- /** {@inheritDoc} */
@Override public UUID originatingNodeId() {
return nodeId;
}
@@ -347,12 +342,6 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
}
/** {@inheritDoc} */
- @Override public IgniteInternalFuture<IgniteInternalTx> prepareAsync() {
- assert false;
- return null;
- }
-
- /** {@inheritDoc} */
@Override public Set<IgniteTxKey> readSet() {
return txState.readSet();
}
@@ -378,11 +367,9 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
}
/**
- * Prepare phase.
- *
- * @throws IgniteCheckedException If prepare failed.
+ * @throws IgniteCheckedException If failed.
*/
- @Override public void prepare() throws IgniteCheckedException {
+ public final void prepareRemoteTx() throws IgniteCheckedException {
// If another thread is doing prepare or rollback.
if (!state(PREPARING)) {
// In optimistic mode prepare may be called multiple times.
@@ -729,7 +716,7 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
}
/** {@inheritDoc} */
- @Override public void commit() throws IgniteCheckedException {
+ @Override public final void commitRemoteTx() throws IgniteCheckedException {
if (optimistic())
state(PREPARED);
@@ -748,7 +735,7 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
if (!isSystemInvalidate())
throw new IgniteCheckedException("Invalid transaction state for commit [state=" + state + ", tx=" + this + ']');
- rollback();
+ rollbackRemoteTx();
}
commitIfLocked();
@@ -766,7 +753,7 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
/** {@inheritDoc} */
@Override public IgniteInternalFuture<IgniteInternalTx> commitAsync() {
try {
- commit();
+ commitRemoteTx();
return new GridFinishedFuture<IgniteInternalTx>(this);
}
@@ -776,8 +763,36 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
}
/** {@inheritDoc} */
- @SuppressWarnings({"CatchGenericClass"})
- @Override public void rollback() {
+ @Override public final IgniteInternalFuture<?> salvageTx() {
+ try {
+ systemInvalidate(true);
+
+ prepareRemoteTx();
+
+ if (state() == PREPARING) {
+ if (log.isDebugEnabled())
+ log.debug("Ignoring transaction in PREPARING state as it is currently handled " +
+ "by another thread: " + this);
+
+ return null;
+ }
+
+ doneRemote(xidVersion(),
+ Collections.<GridCacheVersion>emptyList(),
+ Collections.<GridCacheVersion>emptyList(),
+ Collections.<GridCacheVersion>emptyList());
+
+ commitRemoteTx();
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to invalidate transaction: " + xidVersion(), e);
+ }
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public final void rollbackRemoteTx() {
try {
// Note that we don't evict near entries here -
// they will be deleted by their corresponding transactions.
@@ -796,7 +811,7 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
/** {@inheritDoc} */
@Override public IgniteInternalFuture<IgniteInternalTx> rollbackAsync() {
- rollback();
+ rollbackRemoteTx();
return new GridFinishedFuture<IgniteInternalTx>(this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 dea4072..1e09eda 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
@@ -178,7 +178,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
* @throws GridDistributedLockCancelledException If lock has been cancelled.
*/
@SuppressWarnings({"RedundantTypeArguments"})
- @Nullable GridDhtTxRemote startRemoteTx(UUID nodeId,
+ @Nullable private GridDhtTxRemote startRemoteTx(UUID nodeId,
GridDhtLockRequest req,
GridDhtLockResponse res)
throws IgniteCheckedException, GridDistributedLockCancelledException {
@@ -307,7 +307,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
if (tx.state() == COMMITTING)
tx.forceCommit();
else
- tx.rollback();
+ tx.rollbackRemoteTx();
}
return null;
@@ -362,7 +362,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
if (log.isDebugEnabled())
log.debug("Rolling back remote DHT transaction because it is empty [req=" + req + ", res=" + res + ']');
- tx.rollback();
+ tx.rollbackRemoteTx();
tx = null;
}
@@ -374,7 +374,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
* @param nodeId Node ID.
* @param req Request.
*/
- protected final void processDhtLockRequest(final UUID nodeId, final GridDhtLockRequest req) {
+ private void processDhtLockRequest(final UUID nodeId, final GridDhtLockRequest req) {
if (txLockMsgLog.isDebugEnabled()) {
txLockMsgLog.debug("Received dht lock request [txId=" + req.nearXidVersion() +
", dhtTxId=" + req.version() +
@@ -452,7 +452,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
* @param nodeId Node ID.
* @param req Request.
*/
- protected final void processDhtLockRequest0(UUID nodeId, GridDhtLockRequest req) {
+ private void processDhtLockRequest0(UUID nodeId, GridDhtLockRequest req) {
assert nodeId != null;
assert req != null;
assert !nodeId.equals(locNodeId);
@@ -561,10 +561,10 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
if (fail) {
if (dhtTx != null)
- dhtTx.rollback();
+ dhtTx.rollbackRemoteTx();
if (nearTx != null) // Even though this should never happen, we leave this check for consistency.
- nearTx.rollback();
+ nearTx.rollbackRemoteTx();
List<KeyCacheObject> keys = req.keys();
@@ -602,7 +602,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
* @param nodeId Node ID.
* @param req Request.
*/
- protected void processDhtUnlockRequest(UUID nodeId, GridDhtUnlockRequest req) {
+ private void processDhtUnlockRequest(UUID nodeId, GridDhtUnlockRequest req) {
clearLocks(nodeId, req);
if (isNearEnabled(cacheCfg))
@@ -961,8 +961,8 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
req.futureId(),
req.miniId(),
req.threadId(),
- req.implicitTx(),
- req.implicitSingleTx(),
+ /*implicitTx*/false,
+ /*implicitSingleTx*/false,
ctx.systemTx(),
false,
ctx.ioPolicy(),
@@ -989,7 +989,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
U.warn(log, msg);
if (tx != null)
- tx.rollback();
+ tx.rollbackDhtLocal();
return new GridDhtFinishedFuture<>(new IgniteCheckedException(msg));
}
@@ -1038,31 +1038,12 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
t.xidVersion(),
e);
- if (resp.error() == null && t.onePhaseCommit()) {
- assert t.implicit();
-
- return t.commitAsync().chain(
- new C1<IgniteInternalFuture<IgniteInternalTx>, GridNearLockResponse>() {
- @Override public GridNearLockResponse apply(IgniteInternalFuture<IgniteInternalTx> f) {
- try {
- // Check for error.
- f.get();
- }
- catch (IgniteCheckedException e1) {
- resp.error(e1);
- }
-
- sendLockReply(nearNode, t, req, resp);
-
- return resp;
- }
- });
- }
- else {
- sendLockReply(nearNode, t, req, resp);
+ assert !t.implicit() : t;
+ assert !t.onePhaseCommit() : t;
- return new GridFinishedFuture<>(resp);
- }
+ sendLockReply(nearNode, t, req, resp);
+
+ return new GridFinishedFuture<>(resp);
}
}
);
@@ -1105,7 +1086,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
if (tx != null) {
try {
- tx.rollback();
+ tx.rollbackDhtLocal();
}
catch (IgniteCheckedException ex) {
U.error(log, "Failed to rollback the transaction: " + tx, ex);
@@ -1309,7 +1290,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
*/
private void sendLockReply(
ClusterNode nearNode,
- @Nullable IgniteInternalTx tx,
+ @Nullable GridDhtTxLocal tx,
GridNearLockRequest req,
GridNearLockResponse res
) {
@@ -1347,7 +1328,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
", res=" + res + ']', e);
if (tx != null)
- tx.rollbackAsync();
+ tx.rollbackDhtLocalAsync();
// Convert to closure exception as this method is only called form closures.
throw new GridClosureException(e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 bff69bc..b1c7e5b 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
@@ -292,82 +292,22 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
}
/** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> prepareAsync() {
- if (optimistic()) {
- assert isSystemInvalidate();
-
- return prepareAsync(
- null,
- null,
- Collections.<IgniteTxKey, GridCacheVersion>emptyMap(),
- 0,
- nearMiniId,
- null,
- true);
- }
-
- long timeout = remainingTime();
+ @Override public IgniteInternalFuture<?> salvageTx() {
+ systemInvalidate(true);
- // For pessimistic mode we don't distribute prepare request.
- GridDhtTxPrepareFuture fut = prepFut;
+ state(PREPARED);
- if (fut == null) {
- // Future must be created before any exception can be thrown.
- if (!PREP_FUT_UPD.compareAndSet(this, null, fut = new GridDhtTxPrepareFuture(
- cctx,
- this,
- timeout,
- nearMiniId,
- Collections.<IgniteTxKey, GridCacheVersion>emptyMap(),
- true,
- needReturnValue()))) {
- if (timeout == -1)
- prepFut.onError(timeoutException());
+ if (state() == PREPARING) {
+ if (log.isDebugEnabled())
+ log.debug("Ignoring transaction in PREPARING state as it is currently handled " +
+ "by another thread: " + this);
- return prepFut;
- }
- }
- else
- // Prepare was called explicitly.
- return fut;
-
- if (!state(PREPARING)) {
- if (setRollbackOnly()) {
- if (timeout == -1)
- 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;
+ return null;
}
- try {
- userPrepare();
-
- if (!state(PREPARED)) {
- setRollbackOnly();
-
- fut.onError(new IgniteCheckedException("Invalid transaction state for commit [state=" + state() +
- ", tx=" + this + ']'));
-
- return fut;
- }
+ setRollbackOnly();
- fut.complete();
-
- return fut;
- }
- catch (IgniteCheckedException e) {
- fut.onError(e);
-
- return fut;
- }
+ return rollbackDhtLocalAsync();
}
/**
@@ -382,7 +322,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
* @param last {@code True} if this is last prepare request.
* @return Future that will be completed when locks are acquired.
*/
- public IgniteInternalFuture<GridNearTxPrepareResponse> prepareAsync(
+ public final IgniteInternalFuture<GridNearTxPrepareResponse> prepareAsync(
@Nullable Collection<IgniteTxEntry> reads,
@Nullable Collection<IgniteTxEntry> writes,
Map<IgniteTxKey, GridCacheVersion> verMap,
@@ -478,7 +418,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
fut.onError(new IgniteTxRollbackCheckedException("Failed to prepare transaction: " + this, e));
try {
- rollback();
+ rollbackDhtLocal();
}
catch (IgniteTxOptimisticCheckedException e1) {
if (log.isDebugEnabled())
@@ -523,7 +463,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
if (prepFut != null)
prepFut.get(); // Check for errors.
- boolean finished = finish(commit);
+ boolean finished = localFinish(commit);
if (!finished)
err = new IgniteCheckedException("Failed to finish transaction [commit=" + commit +
@@ -544,16 +484,13 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
fut.finish(commit);
}
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public IgniteInternalFuture<IgniteInternalTx> commitAsync() {
+ /**
+ * @return Commit future.
+ */
+ public IgniteInternalFuture<IgniteInternalTx> commitDhtLocalAsync() {
if (log.isDebugEnabled())
log.debug("Committing dht local tx: " + this);
- // In optimistic mode prepare was called explicitly.
- if (pessimistic())
- prepareAsync();
-
final GridDhtTxFinishFuture fut = new GridDhtTxFinishFuture<>(cctx, this, true);
cctx.mvcc().addFuture(fut, fut.futureId());
@@ -581,15 +518,29 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
}
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public IgniteInternalFuture<IgniteInternalTx> commitAsync() {
+ return commitDhtLocalAsync();
+ }
+
+ /** {@inheritDoc} */
@Override protected void clearPrepareFuture(GridDhtTxPrepareFuture fut) {
assert optimistic();
PREP_FUT_UPD.compareAndSet(this, fut, null);
}
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public IgniteInternalFuture<IgniteInternalTx> rollbackAsync() {
+ /**
+ * @throws IgniteCheckedException If failed.
+ */
+ public void rollbackDhtLocal() throws IgniteCheckedException {
+ rollbackDhtLocalAsync().get();
+ }
+
+ /**
+ * @return Rollback future.
+ */
+ public IgniteInternalFuture<IgniteInternalTx> rollbackDhtLocalAsync() {
final GridDhtTxFinishFuture fut = new GridDhtTxFinishFuture<>(cctx, this, false);
cctx.mvcc().addFuture(fut, fut.futureId());
@@ -612,8 +563,13 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
}
/** {@inheritDoc} */
+ @Override public IgniteInternalFuture<IgniteInternalTx> rollbackAsync() {
+ return rollbackDhtLocalAsync();
+ }
+
+ /** {@inheritDoc} */
@SuppressWarnings({"CatchGenericClass", "ThrowableInstanceNeverThrown"})
- @Override public boolean finish(boolean commit) throws IgniteCheckedException {
+ @Override public boolean localFinish(boolean commit) throws IgniteCheckedException {
assert nearFinFutId != null || isInvalidate() || !commit || isSystemInvalidate()
|| onePhaseCommit() || state() == PREPARED :
"Invalid state [nearFinFutId=" + nearFinFutId + ", isInvalidate=" + isInvalidate() + ", commit=" + commit +
@@ -621,7 +577,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
assert nearMiniId != 0;
- return super.finish(commit);
+ return super.localFinish(commit);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 67e1993..0329386 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
@@ -29,7 +29,6 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
-import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
@@ -161,7 +160,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
/**
* @param node Node.
*/
- public void addLockTransactionNode(ClusterNode node) {
+ void addLockTransactionNode(ClusterNode node) {
assert node != null;
assert !node.isLocal();
@@ -185,7 +184,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
*
* @return Has near cache flag.
*/
- public boolean nearOnOriginatingNode() {
+ boolean nearOnOriginatingNode() {
return nearOnOriginatingNode;
}
@@ -206,7 +205,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
/**
* @return Nodes where transactions were started on lock step.
*/
- @Nullable public Set<ClusterNode> lockTransactionNodes() {
+ @Nullable Set<ClusterNode> lockTransactionNodes() {
return lockTxNodes;
}
@@ -349,14 +348,14 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
/**
* @param mappings Mappings to add.
*/
- void addDhtNodeEntryMapping(Map<ClusterNode, List<GridDhtCacheEntry>> mappings) {
+ private void addDhtNodeEntryMapping(Map<ClusterNode, List<GridDhtCacheEntry>> mappings) {
addMapping(mappings, dhtMap);
}
/**
* @param mappings Mappings to add.
*/
- void addNearNodeEntryMapping(Map<ClusterNode, List<GridDhtCacheEntry>> mappings) {
+ private void addNearNodeEntryMapping(Map<ClusterNode, List<GridDhtCacheEntry>> mappings) {
addMapping(mappings, nearMap);
}
@@ -654,7 +653,6 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
needRetVal,
createTtl,
accessTtl,
- null,
skipStore,
keepBinary);
}
@@ -673,7 +671,6 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
* @param needRetVal Return value flag.
* @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
- * @param filter Entry write filter.
* @param skipStore Skip store flag.
* @return Future for lock acquisition.
*/
@@ -685,7 +682,6 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
final boolean needRetVal,
final long createTtl,
final long accessTtl,
- @Nullable final CacheEntryPredicate[] filter,
boolean skipStore,
boolean keepBinary) {
if (log.isDebugEnabled())
@@ -729,7 +725,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
/*retval*/false,
/*read*/read,
accessTtl,
- filter == null ? CU.empty0() : filter,
+ CU.empty0(),
/*computeInvoke*/false);
return ret;
@@ -740,7 +736,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
/** {@inheritDoc} */
@SuppressWarnings({"CatchGenericClass", "ThrowableInstanceNeverThrown"})
- @Override public boolean finish(boolean commit) throws IgniteCheckedException {
+ @Override public boolean localFinish(boolean commit) throws IgniteCheckedException {
if (log.isDebugEnabled())
log.debug("Finishing dht local tx [tx=" + this + ", commit=" + commit + "]");
@@ -858,16 +854,6 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
}
/** {@inheritDoc} */
- @Override public void rollback() throws IgniteCheckedException {
- try {
- rollbackAsync().get();
- }
- finally {
- cctx.tm().resetContext();
- }
- }
-
- /** {@inheritDoc} */
@Override public String toString() {
return GridToStringBuilder.toString(GridDhtTxLocalAdapter.class, this, "nearNodes", nearMap.keySet(),
"dhtNodes", dhtMap.keySet(), "explicitLock", explicitLock, "super", super.toString());
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 56884ff..93ea30d 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
@@ -718,18 +718,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
CIX1<IgniteInternalFuture<IgniteInternalTx>> resClo =
new CIX1<IgniteInternalFuture<IgniteInternalTx>>() {
@Override public void applyx(IgniteInternalFuture<IgniteInternalTx> fut) {
- try {
- if (REPLIED_UPD.compareAndSet(GridDhtTxPrepareFuture.this, 0, 1))
- sendPrepareResponse(res);
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to send prepare response [txId=" + tx.nearXidVersion() + "," +
- ", dhtTxId=" + tx.xidVersion() +
- ", node=" + tx.nearNodeId() +
- ", res=" + res,
- ", tx=" + tx,
- e);
- }
+ if (REPLIED_UPD.compareAndSet(GridDhtTxPrepareFuture.this, 0, 1))
+ sendPrepareResponse(res);
}
};
@@ -761,18 +751,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
}
}
else {
- try {
- if (REPLIED_UPD.compareAndSet(this, 0, 1))
- sendPrepareResponse(res);
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to send prepare response [txId=" + tx.nearXidVersion() + "," +
- ", dhtTxId=" + tx.xidVersion() +
- ", node=" + tx.nearNodeId() +
- ", res=" + res,
- ", tx=" + tx,
- e);
- }
+ if (REPLIED_UPD.compareAndSet(this, 0, 1))
+ sendPrepareResponse(res);
}
return true;
@@ -784,14 +764,6 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
try {
sendPrepareResponse(res);
}
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to send prepare response [txId=" + tx.nearXidVersion() + "," +
- ", dhtTxId=" + tx.xidVersion() +
- ", node=" + tx.nearNodeId() +
- ", res=" + res,
- ", tx=" + tx,
- e);
- }
finally {
// Will call super.onDone().
onComplete(res);
@@ -819,9 +791,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
/**
* @param res Response.
- * @throws IgniteCheckedException If failed to send response.
*/
- private void sendPrepareResponse(GridNearTxPrepareResponse res) throws IgniteCheckedException {
+ private void sendPrepareResponse(GridNearTxPrepareResponse res) {
if (!tx.nearNodeId().equals(cctx.localNodeId())) {
Throwable err = this.err;
@@ -837,13 +808,31 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
return;
}
- cctx.io().send(tx.nearNodeId(), res, tx.ioPolicy());
+ try {
+ cctx.io().send(tx.nearNodeId(), res, tx.ioPolicy());
- if (msgLog.isDebugEnabled()) {
- msgLog.debug("DHT prepare fut, sent response [txId=" + tx.nearXidVersion() +
+ if (msgLog.isDebugEnabled()) {
+ msgLog.debug("DHT prepare fut, sent response [txId=" + tx.nearXidVersion() +
+ ", dhtTxId=" + tx.xidVersion() +
+ ", node=" + tx.nearNodeId() +
+ ", res=" + res + ']');
+ }
+ }
+ catch (ClusterTopologyCheckedException e) {
+ if (msgLog.isDebugEnabled()) {
+ msgLog.debug("Failed to send prepare response, node left [txId=" + tx.nearXidVersion() + "," +
+ ", dhtTxId=" + tx.xidVersion() +
+ ", node=" + tx.nearNodeId() +
+ ", res=" + res + ']');
+ }
+ }
+ catch (IgniteCheckedException e) {
+ U.error(msgLog, "Failed to send prepare response [txId=" + tx.nearXidVersion() + "," +
", dhtTxId=" + tx.xidVersion() +
", node=" + tx.nearNodeId() +
- ", res=" + res + ']');
+ ", res=" + res,
+ ", tx=" + tx + ']',
+ e);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 e1e0ec2..03bbfe0 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
@@ -207,13 +207,13 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
if (keyCheck)
validateCacheKey(key);
- IgniteTxLocalAdapter tx = ctx.tm().threadLocalTx(ctx);
+ GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx);
final CacheOperationContext opCtx = ctx.operationContextPerCall();
if (tx != null && !tx.implicit() && !skipTx) {
return asyncOp(tx, new AsyncOp<V>() {
- @Override public IgniteInternalFuture<V> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture<V> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
IgniteInternalFuture<Map<Object, Object>> fut = tx.getAllAsync(ctx,
readyTopVer,
Collections.singleton(ctx.toCacheKeyObject(key)),
@@ -289,13 +289,13 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
if (keyCheck)
validateCacheKeys(keys);
- IgniteTxLocalAdapter tx = ctx.tm().threadLocalTx(ctx);
+ GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx);
final CacheOperationContext opCtx = ctx.operationContextPerCall();
if (tx != null && !tx.implicit() && !skipTx) {
return asyncOp(tx, new AsyncOp<Map<K, V>>(keys) {
- @Override public IgniteInternalFuture<Map<K, V>> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture<Map<K, V>> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
return tx.getAllAsync(ctx,
readyTopVer,
ctx.cacheKeysView(keys),
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 0ce380d..79c15fb 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
@@ -917,6 +917,8 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
first = false;
}
+ assert !implicitTx() && !implicitSingleTx() : tx;
+
req = new GridNearLockRequest(
cctx.cacheId(),
topVer,
@@ -925,8 +927,6 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
futId,
lockVer,
inTx(),
- implicitTx(),
- implicitSingleTx(),
read,
retval,
isolation(),
@@ -982,9 +982,6 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
}
}
- if (inTx() && req != null)
- req.hasTransforms(tx.hasTransforms());
-
if (!distributedKeys.isEmpty()) {
mapping.distributedKeys(distributedKeys);
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 ffc84d8..1948df0 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
@@ -1045,6 +1045,8 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
first = false;
}
+ assert !implicitTx() && !implicitSingleTx() : tx;
+
req = new GridNearLockRequest(
cctx.cacheId(),
topVer,
@@ -1053,8 +1055,6 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
futId,
lockVer,
inTx(),
- implicitTx(),
- implicitSingleTx(),
read,
retval,
isolation(),
[15/16] ignite git commit: Fixed assert.
Posted by vo...@apache.org.
Fixed assert.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9020d12f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9020d12f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9020d12f
Branch: refs/heads/ignite-4565-ddl
Commit: 9020d12fc9dbcf39db545b0c8abfc50a324fbd77
Parents: decb0c7
Author: sboikov <sb...@gridgain.com>
Authored: Fri Mar 17 11:24:15 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Mar 17 11:24:15 2017 +0300
----------------------------------------------------------------------
.../cache/distributed/dht/GridDhtPartitionTopologyImpl.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9020d12f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 53257d3..c476886 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -1434,12 +1434,12 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
ClusterNode oldest = discoCache.oldestAliveServerNode();
- assert oldest != null;
+ assert oldest != null || cctx.kernalContext().clientNode();
ClusterNode loc = cctx.localNode();
if (node2part != null) {
- if (oldest.equals(loc) && !node2part.nodeId().equals(loc.id())) {
+ if (loc.equals(oldest) && !node2part.nodeId().equals(loc.id())) {
updateSeq.setIfGreater(node2part.updateSequence());
node2part = new GridDhtPartitionFullMap(loc.id(), loc.order(), updateSeq.incrementAndGet(),
[11/16] ignite git commit: Internal cache API cleanup.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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
index a0f28c5..f9a6353 100644
--- 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
@@ -38,7 +38,6 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteReducer;
@@ -160,8 +159,8 @@ public abstract class GridNearTxPrepareFutureAdapter extends
*
* @param txMapping Transaction mapping.
*/
- protected final void checkOnePhase(GridDhtTxMapping txMapping) {
- if (tx.storeUsed())
+ final void checkOnePhase(GridDhtTxMapping txMapping) {
+ if (tx.storeWriteThrough())
return;
Map<UUID, Collection<UUID>> map = txMapping.transactionNodes();
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 ffeeb51..5b0807f 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
@@ -103,7 +103,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
public GridNearTxPrepareRequest(
IgniteUuid futId,
AffinityTopologyVersion topVer,
- IgniteInternalTx tx,
+ GridNearTxLocal tx,
long timeout,
Collection<IgniteTxEntry> reads,
Collection<IgniteTxEntry> writes,
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 4f4be57..c961f6f 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
@@ -115,7 +115,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
ctx,
nodeId,
xidVer,
- commitVer,
+ commitVer,
sys,
plc,
concurrency,
@@ -289,7 +289,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
*
* @param key Evicted key.
*/
- public void addEvicted(IgniteTxKey key) {
+ void addEvicted(IgniteTxKey key) {
evicted.add(key);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
index d448446..7a69a6f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
@@ -27,10 +27,12 @@ import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.UUID;
import javax.cache.Cache;
import javax.cache.integration.CacheLoaderException;
import javax.cache.integration.CacheWriterException;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cache.store.CacheStore;
import org.apache.ignite.cache.store.CacheStoreSession;
@@ -61,11 +63,17 @@ import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteAsyncSupport;
import org.apache.ignite.lang.IgniteBiInClosure;
import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteProductVersion;
+import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.lifecycle.LifecycleAware;
import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.apache.ignite.transactions.TransactionState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -904,7 +912,7 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
private static class SessionData {
/** */
@GridToStringExclude
- private final IgniteInternalTx tx;
+ private final TxProxy tx;
/** */
private String cacheName;
@@ -914,7 +922,7 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
private Map<Object, Object> props;
/** */
- private Object attachment;
+ private Object attach;
/** */
private final Set<CacheStoreManager> started =
@@ -927,8 +935,8 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
* @param tx Current transaction.
* @param cacheName Cache name.
*/
- private SessionData(@Nullable IgniteInternalTx tx, @Nullable String cacheName) {
- this.tx = tx;
+ private SessionData(@Nullable final IgniteInternalTx tx, @Nullable String cacheName) {
+ this.tx = tx != null ? new TxProxy(tx) : null;
this.cacheName = cacheName;
}
@@ -936,7 +944,7 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
* @return Transaction.
*/
@Nullable private Transaction transaction() {
- return tx != null ? tx.proxy() : null;
+ return tx;
}
/**
@@ -950,12 +958,12 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
}
/**
- * @param attachment Attachment.
+ * @param attach Attachment.
*/
- private Object attach(Object attachment) {
- Object prev = this.attachment;
+ private Object attach(Object attach) {
+ Object prev = this.attach;
- this.attachment = attachment;
+ this.attach = attach;
return prev;
}
@@ -964,7 +972,7 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
* @return Attachment.
*/
private Object attachment() {
- return attachment;
+ return attach;
}
/**
@@ -998,7 +1006,7 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(SessionData.class, this, "tx", CU.txString(tx));
+ return S.toString(SessionData.class, this, "tx", CU.txString(tx != null ? tx.tx : null));
}
}
@@ -1298,4 +1306,116 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
}
}
}
+
+ /**
+ *
+ */
+ private static class TxProxy implements Transaction {
+ /** */
+ private final IgniteInternalTx tx;
+
+ /**
+ * @param tx Transaction.
+ */
+ TxProxy(IgniteInternalTx tx) {
+ assert tx != null;
+
+ this.tx = tx;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteUuid xid() {
+ return tx.xid();
+ }
+
+ /** {@inheritDoc} */
+ @Override public UUID nodeId() {
+ return tx.nodeId();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long threadId() {
+ return tx.threadId();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long startTime() {
+ return tx.startTime();
+ }
+
+ /** {@inheritDoc} */
+ @Override public TransactionIsolation isolation() {
+ return tx.isolation();
+ }
+
+ /** {@inheritDoc} */
+ @Override public TransactionConcurrency concurrency() {
+ return tx.concurrency();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean implicit() {
+ return tx.implicit();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isInvalidate() {
+ return tx.isInvalidate();
+ }
+
+ /** {@inheritDoc} */
+ @Override public TransactionState state() {
+ return tx.state();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long timeout() {
+ return tx.timeout();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long timeout(long timeout) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean setRollbackOnly() {
+ return tx.setRollbackOnly();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isRollbackOnly() {
+ return tx.isRollbackOnly();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void commit() throws IgniteException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() throws IgniteException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void rollback() throws IgniteException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteAsyncSupport withAsync() {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isAsync() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <R> IgniteFuture<R> future() {
+ throw new UnsupportedOperationException();
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 dd900fe..7598003 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
@@ -21,8 +21,6 @@ import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheObject;
@@ -35,7 +33,6 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException;
import org.apache.ignite.internal.util.lang.GridTuple;
-import org.apache.ignite.lang.IgniteAsyncSupported;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;
@@ -45,7 +42,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Transaction managed by cache ({@code 'Ex'} stands for external).
*/
-public interface IgniteInternalTx extends AutoCloseable {
+public interface IgniteInternalTx {
/**
*
*/
@@ -57,9 +54,6 @@ public interface IgniteInternalTx extends AutoCloseable {
/** Transaction is being finalized by user. */
USER_FINISH,
- /** Recovery request is received, user finish requests should be ignored. */
- RECOVERY_WAIT,
-
/** Transaction is being finalized by recovery procedure. */
RECOVERY_FINISH
}
@@ -183,29 +177,6 @@ public interface IgniteInternalTx extends AutoCloseable {
public boolean isRollbackOnly();
/**
- * Commits this transaction by initiating {@code two-phase-commit} process.
- *
- * @throws IgniteCheckedException If commit failed.
- */
- @IgniteAsyncSupported
- public void commit() throws IgniteCheckedException;
-
- /**
- * Ends the transaction. Transaction will be rolled back if it has not been committed.
- *
- * @throws IgniteCheckedException If transaction could not be gracefully ended.
- */
- @Override public void close() throws IgniteCheckedException;
-
- /**
- * Rolls back this transaction.
- *
- * @throws IgniteCheckedException If rollback failed.
- */
- @IgniteAsyncSupported
- public void rollback() throws IgniteCheckedException;
-
- /**
* Removes metadata by key.
*
* @param key Key of the metadata to remove.
@@ -248,7 +219,7 @@ public interface IgniteInternalTx extends AutoCloseable {
* @return {@code True} if transaction is allowed to use store and transactions spans one or more caches with
* store enabled.
*/
- public boolean storeUsed();
+ public boolean storeWriteThrough();
/**
* Checks if this is system cache transaction. System transactions are isolated from user transactions
@@ -306,11 +277,6 @@ public interface IgniteInternalTx extends AutoCloseable {
public boolean empty();
/**
- * @return {@code True} if preparing flag was set with this call.
- */
- public boolean markPreparing();
-
- /**
* @param status Finalization status to set.
* @return {@code True} if could mark was set.
*/
@@ -405,11 +371,6 @@ public interface IgniteInternalTx extends AutoCloseable {
public boolean local();
/**
- * @return {@code True} if transaction is replicated.
- */
- public boolean replicated();
-
- /**
* @return Subject ID initiated this transaction.
*/
public UUID subjectId();
@@ -432,11 +393,6 @@ public interface IgniteInternalTx extends AutoCloseable {
public boolean user();
/**
- * @return Transaction write synchronization mode.
- */
- public CacheWriteSynchronizationMode syncMode();
-
- /**
* @param key Key to check.
* @return {@code True} if key is present.
*/
@@ -524,18 +480,9 @@ public interface IgniteInternalTx extends AutoCloseable {
public void commitVersion(GridCacheVersion commitVer);
/**
- * Prepare state.
- *
- * @throws IgniteCheckedException If failed.
- */
- public void prepare() throws IgniteCheckedException;
-
- /**
- * Prepare stage.
- *
- * @return Future for prepare step.
+ * @return Future.
*/
- public IgniteInternalFuture<?> prepareAsync();
+ @Nullable public IgniteInternalFuture<?> salvageTx();
/**
* @param endVer End version (a.k.a. <tt>'tnc'</tt> or <tt>'transaction number counter'</tt>)
@@ -669,7 +616,8 @@ public interface IgniteInternalTx extends AutoCloseable {
* @param committed Committed transactions relative to base.
* @param rolledback Rolled back transactions relative to base.
*/
- public void completedVersions(GridCacheVersion base, Collection<GridCacheVersion> committed,
+ public void completedVersions(GridCacheVersion base,
+ Collection<GridCacheVersion> committed,
Collection<GridCacheVersion> rolledback);
/**
@@ -683,22 +631,6 @@ public interface IgniteInternalTx extends AutoCloseable {
public boolean onePhaseCommit();
/**
- * @return {@code True} if transaction has transform entries. This flag will be only set for local
- * transactions.
- */
- public boolean hasTransforms();
-
- /**
- * @return Public API proxy.
- */
- public TransactionProxy proxy();
-
- /**
- * @param topVer New topology version.
- */
- public void onRemap(AffinityTopologyVersion topVer);
-
- /**
* @param e Commit error.
*/
public void commitError(Throwable e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 7c7b5a8..ddafbac 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
@@ -22,6 +22,7 @@ import org.apache.ignite.configuration.TransactionConfiguration;
import org.apache.ignite.internal.IgniteTransactionsEx;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.transactions.Transaction;
@@ -91,7 +92,7 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
}
/** {@inheritDoc} */
- @Override public IgniteInternalTx txStartEx(
+ @Override public GridNearTxLocal txStartEx(
GridCacheContext ctx,
TransactionConcurrency concurrency,
TransactionIsolation isolation,
@@ -113,7 +114,7 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
}
/** {@inheritDoc} */
- @Override public IgniteInternalTx txStartEx(
+ @Override public GridNearTxLocal txStartEx(
GridCacheContext ctx,
TransactionConcurrency concurrency,
TransactionIsolation isolation)
@@ -141,7 +142,7 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
* @return Transaction.
*/
@SuppressWarnings("unchecked")
- private IgniteInternalTx txStart0(
+ private GridNearTxLocal txStart0(
TransactionConcurrency concurrency,
TransactionIsolation isolation,
long timeout,
@@ -151,11 +152,12 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
cctx.kernalContext().gateway().readLock();
try {
- IgniteInternalTx tx = cctx.tm().userTx(sysCacheCtx);
+ GridNearTxLocal tx = cctx.tm().userTx(sysCacheCtx);
if (tx != null)
throw new IllegalStateException("Failed to start new transaction " +
"(current thread already has a transaction): " + tx);
+
tx = cctx.tm().newTx(
false,
false,
@@ -178,7 +180,7 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
/** {@inheritDoc} */
@Nullable @Override public Transaction tx() {
- IgniteInternalTx tx = cctx.tm().userTx();
+ GridNearTxLocal tx = cctx.tm().userTx();
return tx != null ? tx.proxy() : null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 b07a117..13ca26a 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
@@ -39,7 +39,6 @@ import javax.cache.expiry.ExpiryPolicy;
import javax.cache.processor.EntryProcessor;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -91,7 +90,6 @@ import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
import static org.apache.ignite.transactions.TransactionState.ACTIVE;
-import static org.apache.ignite.transactions.TransactionState.COMMITTED;
import static org.apache.ignite.transactions.TransactionState.COMMITTING;
import static org.apache.ignite.transactions.TransactionState.MARKED_ROLLBACK;
import static org.apache.ignite.transactions.TransactionState.PREPARED;
@@ -192,12 +190,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
/** */
protected boolean onePhaseCommit;
- /** */
- protected CacheWriteSynchronizationMode syncMode;
-
- /** If this transaction contains transform entries. */
- protected boolean transform;
-
/** Commit version. */
private volatile GridCacheVersion commitVer;
@@ -207,9 +199,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
/** Done marker. */
protected volatile boolean isDone;
- /** Preparing flag (no need for volatile modifier). */
- private boolean preparing;
-
/** */
@GridToStringInclude
private Map<Integer, Set<Integer>> invalidParts;
@@ -251,10 +240,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
/** Store used flag. */
protected boolean storeEnabled = true;
- /** */
- @GridToStringExclude
- private TransactionProxyImpl proxy;
-
/**
* Empty constructor required for {@link Externalizable}.
*/
@@ -420,8 +405,8 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public boolean storeUsed() {
- return storeEnabled() && txState().storeUsed(cctx);
+ @Override public boolean storeWriteThrough() {
+ return storeEnabled() && txState().storeWriteThrough(cctx);
}
/**
@@ -512,32 +497,10 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
}
- /** {@inheritDoc} */
- @Override public void onRemap(AffinityTopologyVersion topVer) {
- assert false : this;
- }
-
- /** {@inheritDoc} */
- @Override public boolean hasTransforms() {
- return transform;
- }
-
- /** {@inheritDoc} */
- @Override public boolean markPreparing() {
- synchronized (this) {
- if (preparing)
- return false;
-
- preparing = true;
-
- return true;
- }
- }
-
/**
* @return {@code True} if marked.
*/
- @Override public boolean markFinalizing(FinalizationStatus status) {
+ @Override public final boolean markFinalizing(FinalizationStatus status) {
boolean res;
switch (status) {
@@ -546,15 +509,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
break;
- case RECOVERY_WAIT:
- FINALIZING_UPD.compareAndSet(this, FinalizationStatus.NONE, FinalizationStatus.RECOVERY_WAIT);
-
- FinalizationStatus cur = finalizing;
-
- res = cur == FinalizationStatus.RECOVERY_WAIT || cur == FinalizationStatus.RECOVERY_FINISH;
-
- break;
-
case RECOVERY_FINISH:
FinalizationStatus old = finalizing;
@@ -564,7 +518,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
default:
throw new IllegalArgumentException("Cannot set finalization status: " + status);
-
}
if (res) {
@@ -639,26 +592,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public boolean replicated() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public CacheWriteSynchronizationMode syncMode() {
- if (syncMode != null)
- return syncMode;
-
- return txState().syncMode(cctx);
- }
-
- /**
- * @param syncMode Write synchronization mode.
- */
- public void syncMode(CacheWriteSynchronizationMode syncMode) {
- this.syncMode = syncMode;
- }
-
- /** {@inheritDoc} */
@Override public IgniteUuid xid() {
return xidVer.asGridUuid();
}
@@ -911,30 +844,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
}
- /**
- *
- */
- @Override public void close() throws IgniteCheckedException {
- TransactionState state = state();
-
- if (state != ROLLING_BACK && state != ROLLED_BACK && state != COMMITTING && state != COMMITTED)
- rollback();
-
- synchronized (this) {
- try {
- while (!done())
- wait();
- }
- catch (InterruptedException e) {
- Thread.currentThread().interrupt();
-
- if (!done())
- throw new IgniteCheckedException("Got interrupted while waiting for transaction to complete: " +
- this, e);
- }
- }
- }
-
/** {@inheritDoc} */
@Override public boolean needsCompletedVersions() {
return false;
@@ -1190,12 +1099,12 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public boolean isSystemInvalidate() {
+ @Override public final boolean isSystemInvalidate() {
return sysInvalidate;
}
/** {@inheritDoc} */
- @Override public void systemInvalidate(boolean sysInvalidate) {
+ @Override public final void systemInvalidate(boolean sysInvalidate) {
this.sysInvalidate = sysInvalidate;
}
@@ -1257,7 +1166,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
* @throws IgniteCheckedException If batch update failed.
*/
@SuppressWarnings({"CatchGenericClass"})
- protected void batchStoreCommit(Iterable<IgniteTxEntry> writeEntries) throws IgniteCheckedException {
+ protected final void batchStoreCommit(Iterable<IgniteTxEntry> writeEntries) throws IgniteCheckedException {
if (!storeEnabled() || internal() ||
(!local() && near())) // No need to work with local store at GridNearTxRemote.
return;
@@ -1806,14 +1715,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public TransactionProxy proxy() {
- if (proxy == null)
- proxy = new TransactionProxyImpl(this, cctx, false);
-
- return proxy;
- }
-
- /** {@inheritDoc} */
@Override public boolean equals(Object o) {
return o == this || (o instanceof IgniteTxAdapter && xidVer.equals(((IgniteTxAdapter)o).xidVer));
}
@@ -1972,21 +1873,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public void commit() {
- throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
- }
-
- /** {@inheritDoc} */
- @Override public void close() {
- throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
- }
-
- /** {@inheritDoc} */
- @Override public void rollback() {
- throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
- }
-
- /** {@inheritDoc} */
@Override public boolean activeCachesDeploymentEnabled() {
return false;
}
@@ -2017,7 +1903,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public boolean storeUsed() {
+ @Override public boolean storeWriteThrough() {
throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
}
@@ -2051,11 +1937,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public void onRemap(AffinityTopologyVersion topVer) {
- throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
- }
-
- /** {@inheritDoc} */
@Override public void commitError(Throwable e) {
throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
}
@@ -2066,11 +1947,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public boolean markPreparing() {
- throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
- }
-
- /** {@inheritDoc} */
@Override public boolean markFinalizing(FinalizationStatus status) {
throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
}
@@ -2156,11 +2032,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public boolean replicated() {
- return false;
- }
-
- /** {@inheritDoc} */
@Override public UUID subjectId() {
return null;
}
@@ -2176,11 +2047,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public CacheWriteSynchronizationMode syncMode() {
- return null;
- }
-
- /** {@inheritDoc} */
@Override public boolean hasWriteKey(IgniteTxKey key) {
return false;
}
@@ -2258,12 +2124,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public void prepare() throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<IgniteInternalTx> prepareAsync() {
+ @Override public IgniteInternalFuture<?> salvageTx() {
return null;
}
@@ -2393,16 +2254,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public boolean hasTransforms() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public TransactionProxy proxy() {
- return null;
- }
-
- /** {@inheritDoc} */
@Override public boolean equals(Object o) {
return this == o || o instanceof IgniteInternalTx && xid.equals(((IgniteInternalTx)o).xid());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 14a7ed0..e1d12af 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
@@ -423,7 +423,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
/**
* @param val Value to set.
*/
- void setAndMarkValid(CacheObject val) {
+ public void setAndMarkValid(CacheObject val) {
setAndMarkValid(op(), val, this.val.hasWriteValue(), this.val.hasReadValue());
}
@@ -451,7 +451,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
* Marks this entry as value-has-bean-read. Effectively, makes values enlisted to transaction visible
* to further peek operations.
*/
- void markValid() {
+ public void markValid() {
prevVal.value(val.op(), val.value(), val.hasWriteValue(), val.hasReadValue());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 56a7fa2..be48de7 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
@@ -255,7 +255,7 @@ public class IgniteTxHandler {
req.last());
if (locTx.isRollbackOnly())
- locTx.rollbackAsync();
+ locTx.rollbackNearTxLocalAsync();
return fut.chain(new C1<IgniteInternalFuture<GridNearTxPrepareResponse>, GridNearTxPrepareResponse>() {
@Override public GridNearTxPrepareResponse apply(IgniteInternalFuture<GridNearTxPrepareResponse> f) {
@@ -491,7 +491,7 @@ public class IgniteTxHandler {
if (tx.isRollbackOnly() && !tx.commitOnPrepare()) {
if (tx.state() != TransactionState.ROLLED_BACK && tx.state() != TransactionState.ROLLING_BACK)
- tx.rollbackAsync();
+ tx.rollbackDhtLocalAsync();
}
final GridDhtTxLocal tx0 = tx;
@@ -711,8 +711,10 @@ public class IgniteTxHandler {
* @param req Request.
* @return Future.
*/
- @Nullable public IgniteInternalFuture<IgniteInternalTx> finish(UUID nodeId, @Nullable GridNearTxLocal locTx,
- GridNearTxFinishRequest req) {
+ @Nullable public IgniteInternalFuture<IgniteInternalTx> finish(UUID nodeId,
+ @Nullable GridNearTxLocal locTx,
+ GridNearTxFinishRequest req)
+ {
assert nodeId != null;
assert req != null;
@@ -763,8 +765,10 @@ public class IgniteTxHandler {
* @param req Finish request.
* @return Finish future.
*/
- private IgniteInternalFuture<IgniteInternalTx> finishDhtLocal(UUID nodeId, @Nullable GridNearTxLocal locTx,
- GridNearTxFinishRequest req) {
+ private IgniteInternalFuture<IgniteInternalTx> finishDhtLocal(UUID nodeId,
+ @Nullable GridNearTxLocal locTx,
+ GridNearTxFinishRequest req)
+ {
GridCacheVersion dhtVer = ctx.tm().mappedVersion(req.version());
GridDhtTxLocal tx = null;
@@ -845,10 +849,11 @@ public class IgniteTxHandler {
assert req.syncMode() != null : req;
tx.syncMode(req.syncMode());
+ tx.nearFinishFutureId(req.futureId());
+ tx.nearFinishMiniId(req.miniId());
+ tx.storeEnabled(req.storeEnabled());
if (req.commit()) {
- tx.storeEnabled(req.storeEnabled());
-
if (!tx.markFinalizing(USER_FINISH)) {
if (log.isDebugEnabled())
log.debug("Will not finish transaction (it is handled by another thread): " + tx);
@@ -856,10 +861,7 @@ public class IgniteTxHandler {
return null;
}
- tx.nearFinishFutureId(req.futureId());
- tx.nearFinishMiniId(req.miniId());
-
- IgniteInternalFuture<IgniteInternalTx> commitFut = tx.commitAsync();
+ IgniteInternalFuture<IgniteInternalTx> commitFut = tx.commitDhtLocalAsync();
// Only for error logging.
commitFut.listen(CU.errorLogger(log));
@@ -867,10 +869,7 @@ public class IgniteTxHandler {
return commitFut;
}
else {
- tx.nearFinishFutureId(req.futureId());
- tx.nearFinishMiniId(req.miniId());
-
- IgniteInternalFuture<IgniteInternalTx> rollbackFut = tx.rollbackAsync();
+ IgniteInternalFuture<IgniteInternalTx> rollbackFut = tx.rollbackDhtLocalAsync();
// Only for error logging.
rollbackFut.listen(CU.errorLogger(log));
@@ -887,7 +886,7 @@ public class IgniteTxHandler {
IgniteInternalFuture<IgniteInternalTx> res;
- IgniteInternalFuture<IgniteInternalTx> rollbackFut = tx.rollbackAsync();
+ IgniteInternalFuture<IgniteInternalTx> rollbackFut = tx.rollbackDhtLocalAsync();
// Only for error logging.
rollbackFut.listen(CU.errorLogger(log));
@@ -928,7 +927,7 @@ public class IgniteTxHandler {
throw e;
if (tx != null)
- return tx.rollbackAsync();
+ return tx.rollbackNearTxLocalAsync();
return new GridFinishedFuture<>(e);
}
@@ -1011,7 +1010,7 @@ public class IgniteTxHandler {
U.error(log, "Failed to process prepare request: " + req, e);
if (nearTx != null)
- nearTx.rollback();
+ nearTx.rollbackRemoteTx();
res = new GridDhtTxPrepareResponse(
req.partition(),
@@ -1153,7 +1152,7 @@ public class IgniteTxHandler {
if (completeFut != null) {
completeFut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
- @Override public void apply(IgniteInternalFuture<IgniteInternalTx> igniteTxIgniteFuture) {
+ @Override public void apply(IgniteInternalFuture<IgniteInternalTx> fut) {
sendReply(nodeId, req, true, nearTxId);
}
});
@@ -1212,12 +1211,12 @@ public class IgniteTxHandler {
tx.setPartitionUpdateCounters(
req.partUpdateCounters() != null ? req.partUpdateCounters().array() : null);
- tx.commit();
+ tx.commitRemoteTx();
}
else {
tx.doneRemote(req.baseVersion(), null, null, null);
- tx.rollback();
+ tx.rollbackRemoteTx();
}
}
catch (Throwable e) {
@@ -1228,7 +1227,7 @@ public class IgniteTxHandler {
tx.systemInvalidate(true);
try {
- tx.commit();
+ tx.commitRemoteTx();
}
catch (IgniteCheckedException ex) {
U.error(log, "Failed to invalidate transaction: " + tx, ex);
@@ -1255,7 +1254,7 @@ public class IgniteTxHandler {
// Complete remote candidates.
tx.doneRemote(req.version(), null, null, null);
- tx.commit();
+ tx.commitRemoteTx();
}
catch (IgniteTxHeuristicCheckedException e) {
// Just rethrow this exception. Transaction was already uncommitted.
@@ -1268,7 +1267,7 @@ public class IgniteTxHandler {
tx.invalidate(true);
tx.systemInvalidate(true);
- tx.rollback();
+ tx.rollbackRemoteTx();
if (e instanceof Error)
throw (Error)e;
@@ -1282,7 +1281,7 @@ public class IgniteTxHandler {
* @param dhtTx Dht tx.
* @param nearTx Near tx.
*/
- protected void sendReply(UUID nodeId,
+ private void sendReply(UUID nodeId,
GridDhtTxPrepareRequest req,
GridDhtTxPrepareResponse res,
GridDhtTxRemote dhtTx,
@@ -1314,10 +1313,10 @@ public class IgniteTxHandler {
}
if (nearTx != null)
- nearTx.rollback();
+ nearTx.rollbackRemoteTx();
if (dhtTx != null)
- dhtTx.rollback();
+ dhtTx.rollbackRemoteTx();
}
}
@@ -1329,7 +1328,7 @@ public class IgniteTxHandler {
* @param committed {@code True} if transaction committed on this node.
* @param nearTxId Near tx version.
*/
- protected final void sendReply(UUID nodeId, GridDhtTxFinishRequest req, boolean committed, GridCacheVersion nearTxId) {
+ private void sendReply(UUID nodeId, GridDhtTxFinishRequest req, boolean committed, GridCacheVersion nearTxId) {
if (req.replyRequired() || req.checkCommitted()) {
GridDhtTxFinishResponse res = new GridDhtTxFinishResponse(
req.partition(),
@@ -1551,21 +1550,19 @@ public class IgniteTxHandler {
// Prepare prior to reordering, so the pending locks added
// in prepare phase will get properly ordered as well.
- tx.prepare();
+ tx.prepareRemoteTx();
if (req.last()) {
assert !F.isEmpty(req.transactionNodes()) :
"Received last prepare request with empty transaction nodes: " + req;
- tx.transactionNodes(req.transactionNodes());
-
tx.state(PREPARED);
}
res.invalidPartitionsByCacheId(tx.invalidPartitions());
if (tx.empty() && req.last()) {
- tx.rollback();
+ tx.rollbackRemoteTx();
return null;
}
@@ -1644,7 +1641,7 @@ public class IgniteTxHandler {
// Prepare prior to reordering, so the pending locks added
// in prepare phase will get properly ordered as well.
- tx.prepare();
+ tx.prepareRemoteTx();
if (req.last())
tx.state(PREPARED);
@@ -1659,7 +1656,7 @@ public class IgniteTxHandler {
* @param nodeId Node ID.
* @param req Request.
*/
- protected void processCheckPreparedTxRequest(final UUID nodeId,
+ private void processCheckPreparedTxRequest(final UUID nodeId,
final GridCacheTxRecoveryRequest req) {
if (txRecoveryMsgLog.isDebugEnabled()) {
txRecoveryMsgLog.debug("Received tx recovery request [txId=" + req.nearXidVersion() +
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java
index bffb295..9417e1f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java
@@ -154,13 +154,13 @@ public class IgniteTxImplicitSingleStateImpl extends IgniteTxLocalStateAdapter {
}
/** {@inheritDoc} */
- @Override public boolean storeUsed(GridCacheSharedContext cctx) {
+ @Override public boolean storeWriteThrough(GridCacheSharedContext cctx) {
if (cacheCtx == null)
return false;
CacheStoreManager store = cacheCtx.store();
- return store.configured();
+ return store.configured() && store.isWriteThrough();
}
/** {@inheritDoc} */
[06/16] ignite git commit: IGNITE-824: Removed
GridRandomSelfTest.testPerformance(). This closes #1566.
Posted by vo...@apache.org.
IGNITE-824: Removed GridRandomSelfTest.testPerformance(). This closes #1566.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e8e52362
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e8e52362
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e8e52362
Branch: refs/heads/ignite-4565-ddl
Commit: e8e52362414ad55f7360ce8a5e689dd9af745bd6
Parents: cd0bc4f
Author: devozerov <vo...@gridgain.com>
Authored: Thu Mar 16 14:49:54 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Thu Mar 16 14:49:54 2017 +0300
----------------------------------------------------------------------
.../src/test/java/org/apache/ignite/util/GridRandomSelfTest.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8e52362/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java
index 1310c4e..e965433 100644
--- a/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java
@@ -21,7 +21,6 @@ import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import junit.framework.TestCase;
import org.apache.ignite.internal.util.GridRandom;
-import org.apache.ignite.internal.util.typedef.X;
/**
* Test for {@link GridRandom}.
[13/16] ignite git commit: Internal cache API cleanup.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 229961e..48b508b 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
@@ -46,6 +46,15 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
/** */
private static final long serialVersionUID = 0L;
+ /** */
+ private static final int NEED_RETURN_VALUE_FLAG_MASK = 0x01;
+
+ /** */
+ private static final int FIRST_CLIENT_REQ_FLAG_MASK = 0x02;
+
+ /** */
+ private static final int SYNC_COMMIT_FLAG_MASK = 0x04;
+
/** Topology version. */
private AffinityTopologyVersion topVer;
@@ -55,15 +64,6 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
/** Filter. */
private CacheEntryPredicate[] filter;
- /** Implicit flag. */
- private boolean implicitTx;
-
- /** Implicit transaction with one key flag. */
- private boolean implicitSingleTx;
-
- /** Flag is kept for backward compatibility. */
- private boolean onePhaseCommit;
-
/** Array of mapped DHT versions for this entry. */
@GridToStringInclude
private GridCacheVersion[] dhtVers;
@@ -74,23 +74,14 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
/** Task name hash. */
private int taskNameHash;
- /** Has transforms flag. */
- private boolean hasTransforms;
-
- /** Sync commit flag. */
- private boolean syncCommit;
-
/** TTL for create operation. */
private long createTtl;
/** TTL for read operation. */
private long accessTtl;
- /** Flag indicating whether cache operation requires a previous value. */
- private boolean retVal;
-
- /** {@code True} if first lock request for lock operation sent from client node. */
- private boolean firstClientReq;
+ /** */
+ private byte flags;
/**
* Empty constructor required for {@link Externalizable}.
@@ -107,8 +98,6 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
* @param futId Future ID.
* @param lockVer Cache version.
* @param isInTx {@code True} if implicit transaction lock.
- * @param implicitTx Flag to indicate that transaction is implicit.
- * @param implicitSingleTx Implicit-transaction-with-one-key flag.
* @param isRead Indicates whether implicit lock is for read or write operation.
* @param retVal Return value flag.
* @param isolation Transaction isolation.
@@ -133,8 +122,6 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
IgniteUuid futId,
GridCacheVersion lockVer,
boolean isInTx,
- boolean implicitTx,
- boolean implicitSingleTx,
boolean isRead,
boolean retVal,
TransactionIsolation isolation,
@@ -174,24 +161,43 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
assert topVer.compareTo(AffinityTopologyVersion.ZERO) > 0;
this.topVer = topVer;
- this.implicitTx = implicitTx;
- this.implicitSingleTx = implicitSingleTx;
- this.syncCommit = syncCommit;
this.subjId = subjId;
this.taskNameHash = taskNameHash;
this.createTtl = createTtl;
this.accessTtl = accessTtl;
- this.retVal = retVal;
- this.firstClientReq = firstClientReq;
dhtVers = new GridCacheVersion[keyCnt];
+
+ setFlag(syncCommit, SYNC_COMMIT_FLAG_MASK);
+ setFlag(firstClientReq, FIRST_CLIENT_REQ_FLAG_MASK);
+ setFlag(retVal, NEED_RETURN_VALUE_FLAG_MASK);
+ }
+
+ /**
+ * Sets flag mask.
+ *
+ * @param flag Set or clear.
+ * @param mask Mask.
+ */
+ private void setFlag(boolean flag, int mask) {
+ flags = flag ? (byte)(flags | mask) : (byte)(flags & ~mask);
+ }
+
+ /**
+ * Reags flag mask.
+ *
+ * @param mask Mask to read.
+ * @return Flag value.
+ */
+ private boolean isFlag(int mask) {
+ return (flags & mask) != 0;
}
/**
* @return {@code True} if first lock request for lock operation sent from client node.
*/
public boolean firstClientRequest() {
- return firstClientReq;
+ return isFlag(FIRST_CLIENT_REQ_FLAG_MASK);
}
/**
@@ -216,24 +222,10 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
}
/**
- * @return Implicit transaction flag.
- */
- public boolean implicitTx() {
- return implicitTx;
- }
-
- /**
- * @return Implicit-transaction-with-one-key flag.
- */
- public boolean implicitSingleTx() {
- return implicitSingleTx;
- }
-
- /**
* @return Sync commit flag.
*/
public boolean syncCommit() {
- return syncCommit;
+ return isFlag(SYNC_COMMIT_FLAG_MASK);
}
/**
@@ -268,24 +260,10 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
}
/**
- * @param hasTransforms {@code True} if originating transaction has transform entries.
- */
- public void hasTransforms(boolean hasTransforms) {
- this.hasTransforms = hasTransforms;
- }
-
- /**
- * @return {@code True} if originating transaction has transform entries.
- */
- public boolean hasTransforms() {
- return hasTransforms;
- }
-
- /**
* @return Need return value flag.
*/
public boolean needReturnValue() {
- return retVal;
+ return isFlag(NEED_RETURN_VALUE_FLAG_MASK);
}
/**
@@ -399,66 +377,30 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
writer.incrementState();
case 24:
- if (!writer.writeBoolean("firstClientReq", firstClientReq))
+ if (!writer.writeByte("flags", flags))
return false;
writer.incrementState();
case 25:
- if (!writer.writeBoolean("hasTransforms", hasTransforms))
- return false;
-
- writer.incrementState();
-
- case 26:
- if (!writer.writeBoolean("implicitSingleTx", implicitSingleTx))
- return false;
-
- writer.incrementState();
-
- case 27:
- if (!writer.writeBoolean("implicitTx", implicitTx))
- return false;
-
- writer.incrementState();
-
- case 28:
if (!writer.writeInt("miniId", miniId))
return false;
writer.incrementState();
- case 29:
- if (!writer.writeBoolean("onePhaseCommit", onePhaseCommit))
- return false;
-
- writer.incrementState();
-
- case 30:
- if (!writer.writeBoolean("retVal", retVal))
- return false;
-
- writer.incrementState();
-
- case 31:
+ case 26:
if (!writer.writeUuid("subjId", subjId))
return false;
writer.incrementState();
- case 32:
- if (!writer.writeBoolean("syncCommit", syncCommit))
- return false;
-
- writer.incrementState();
-
- case 33:
+ case 27:
if (!writer.writeInt("taskNameHash", taskNameHash))
return false;
writer.incrementState();
- case 34:
+ case 28:
if (!writer.writeMessage("topVer", topVer))
return false;
@@ -513,7 +455,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 24:
- firstClientReq = reader.readBoolean("firstClientReq");
+ flags = reader.readByte("flags");
if (!reader.isLastRead())
return false;
@@ -521,30 +463,6 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 25:
- hasTransforms = reader.readBoolean("hasTransforms");
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 26:
- implicitSingleTx = reader.readBoolean("implicitSingleTx");
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 27:
- implicitTx = reader.readBoolean("implicitTx");
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 28:
miniId = reader.readInt("miniId");
if (!reader.isLastRead())
@@ -552,23 +470,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 29:
- onePhaseCommit = reader.readBoolean("onePhaseCommit");
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 30:
- retVal = reader.readBoolean("retVal");
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 31:
+ case 26:
subjId = reader.readUuid("subjId");
if (!reader.isLastRead())
@@ -576,15 +478,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 32:
- syncCommit = reader.readBoolean("syncCommit");
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 33:
+ case 27:
taskNameHash = reader.readInt("taskNameHash");
if (!reader.isLastRead())
@@ -592,7 +486,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
- case 34:
+ case 28:
topVer = reader.readMessage("topVer");
if (!reader.isLastRead())
@@ -612,7 +506,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 35;
+ return 29;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 940dd80..5ad05b0 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
@@ -133,7 +133,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
if (keyCheck)
validateCacheKeys(keys);
- IgniteTxLocalAdapter tx = ctx.tm().threadLocalTx(ctx);
+ GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx);
CacheOperationContext opCtx = ctx.operationContextPerCall();
@@ -141,7 +141,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
if (tx != null && !tx.implicit() && !skipTx) {
return asyncOp(tx, new AsyncOp<Map<K, V>>(keys) {
- @Override public IgniteInternalFuture<Map<K, V>> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+ @Override public IgniteInternalFuture<Map<K, V>> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
return tx.getAllAsync(ctx,
readyTopVer,
ctx.cacheKeysView(keys),
@@ -377,7 +377,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
log.debug("Node requesting lock left grid (lock request will be ignored): " + req);
if (tx != null)
- tx.rollback();
+ tx.rollbackRemoteTx();
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
index 7387501..1b0566b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
@@ -310,7 +310,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
err = new TransactionRollbackException("Failed to commit transaction.", err);
try {
- tx.finish(err == null);
+ tx.localFinish(err == null);
}
catch (IgniteCheckedException e) {
if (err != null)
@@ -402,7 +402,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
}
try {
- if (tx.finish(commit) || (!commit && tx.state() == UNKNOWN)) {
+ if (tx.localFinish(commit) || (!commit && tx.state() == UNKNOWN)) {
if ((tx.onePhaseCommit() && needFinishOnePhase(commit)) || (!tx.onePhaseCommit() && mappings != null)) {
if (mappings.single()) {
GridDistributedTxMapping mapping = mappings.singleMapping();
[02/16] ignite git commit: IGNITE-4729 Async operation support in
platform plugins
Posted by vo...@apache.org.
IGNITE-4729 Async operation support in platform plugins
This closes #1561
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/637c18de
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/637c18de
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/637c18de
Branch: refs/heads/ignite-4565-ddl
Commit: 637c18de190515293e01434862004a410cfadd53
Parents: be93baa
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Wed Mar 15 14:02:12 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Wed Mar 15 14:02:12 2017 +0300
----------------------------------------------------------------------
.../platform/PlatformAbstractTarget.java | 8 ++
.../platform/PlatformAsyncResult.java | 41 +++++++++
.../processors/platform/PlatformTarget.java | 10 +++
.../platform/PlatformTargetProxy.java | 9 ++
.../platform/PlatformTargetProxyImpl.java | 39 +++++++++
.../plugin/PlatformTestPluginTarget.java | 89 +++++++++++++++++++-
.../cpp/jni/include/ignite/jni/exports.h | 1 +
.../platforms/cpp/jni/include/ignite/jni/java.h | 2 +
modules/platforms/cpp/jni/project/vs/module.def | 1 +
modules/platforms/cpp/jni/src/exports.cpp | 4 +
modules/platforms/cpp/jni/src/java.cpp | 10 +++
.../Plugin/PluginTest.cs | 17 ++++
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 29 +++++++
.../Impl/Unmanaged/IgniteJniNativeMethods.cs | 3 +
.../Impl/Unmanaged/UnmanagedUtils.cs | 5 ++
.../Interop/IPlatformTarget.cs | 13 +++
16 files changed, 277 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
index 506470b..396e784 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
@@ -125,6 +125,14 @@ public abstract class PlatformAbstractTarget implements PlatformTarget, Platform
return throwUnsupported(type);
}
+ /** {@inheritDoc} */
+ @Override public PlatformAsyncResult processInStreamAsync(int type, BinaryRawReaderEx reader)
+ throws IgniteCheckedException {
+ throwUnsupported(type);
+
+ return null;
+ }
+
/**
* Throw an exception rendering unsupported operation type.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAsyncResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAsyncResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAsyncResult.java
new file mode 100644
index 0000000..879f85d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAsyncResult.java
@@ -0,0 +1,41 @@
+/*
+ * 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.platform;
+
+import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.lang.IgniteFuture;
+
+/**
+ * Represents asynchronous operation result.
+ */
+public interface PlatformAsyncResult {
+ /**
+ * Async operation future.
+ *
+ * @return Future.
+ */
+ IgniteFuture future();
+
+ /**
+ * Async operation result writer method.
+ *
+ * @param writer Writer.
+ * @param result Async operation result.
+ */
+ void write(BinaryRawWriterEx writer, Object result);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java
index 5d234dd..9792df8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTarget.java
@@ -108,6 +108,16 @@ public interface PlatformTarget {
PlatformTarget processOutObject(int type) throws IgniteCheckedException;
/**
+ * Process asynchronous operation.
+ *
+ * @param type Type.
+ * @param reader Binary reader.
+ * @return Async result (should not be null).
+ * @throws IgniteCheckedException In case of exception.
+ */
+ PlatformAsyncResult processInStreamAsync(int type, BinaryRawReaderEx reader) throws IgniteCheckedException;
+
+ /**
* Convert caught exception.
*
* @param e Exception to convert.
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxy.java
index a4f2a56..c2a0797 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxy.java
@@ -97,6 +97,15 @@ public interface PlatformTargetProxy {
Object outObject(int type) throws Exception;
/**
+ * Asynchronous operation accepting memory stream.
+ *
+ * @param type Operation type.
+ * @param memPtr Memory pointer.
+ * @throws Exception If case of failure.
+ */
+ void inStreamAsync(int type, long memPtr) throws Exception;
+
+ /**
* Start listening for the future.
*
* @param futId Future ID.
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxyImpl.java
index 25a4de8..7e0036d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxyImpl.java
@@ -18,12 +18,14 @@
package org.apache.ignite.internal.processors.platform;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
import org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils;
+import org.apache.ignite.lang.IgniteFuture;
/**
* Platform target that is invoked via JNI and propagates calls to underlying {@link PlatformTarget}.
@@ -104,6 +106,43 @@ public class PlatformTargetProxyImpl implements PlatformTargetProxy {
}
/** {@inheritDoc} */
+ @Override public void inStreamAsync(int type, long memPtr) throws Exception {
+ try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
+ BinaryRawReaderEx reader = platformCtx.reader(mem);
+
+ long futId = reader.readLong();
+ int futTyp = reader.readInt();
+
+ final PlatformAsyncResult res = target.processInStreamAsync(type, reader);
+
+ if (res == null) {
+ throw new IgniteException("PlatformTarget.processInStreamAsync should not return null.");
+ }
+
+ IgniteFuture fut = res.future();
+
+ if (fut == null) {
+ throw new IgniteException("PlatformAsyncResult.future() should not return null.");
+ }
+
+ PlatformFutureUtils.listen(platformCtx, fut, futId, futTyp, new PlatformFutureUtils.Writer() {
+ /** {@inheritDoc} */
+ @Override public void write(BinaryRawWriterEx writer, Object obj, Throwable err) {
+ res.write(writer, obj);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean canWrite(Object obj, Throwable err) {
+ return err == null;
+ }
+ }, target);
+ }
+ catch (Exception e) {
+ throw target.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void inStreamOutStream(int type, long inMemPtr, long outMemPtr) throws Exception {
try (PlatformMemory inMem = platformCtx.memory().get(inMemPtr)) {
BinaryRawReaderEx reader = platformCtx.reader(inMem);
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/core/src/test/java/org/apache/ignite/platform/plugin/PlatformTestPluginTarget.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/plugin/PlatformTestPluginTarget.java b/modules/core/src/test/java/org/apache/ignite/platform/plugin/PlatformTestPluginTarget.java
index e80a23f..7e69425 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/plugin/PlatformTestPluginTarget.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/plugin/PlatformTestPluginTarget.java
@@ -21,11 +21,14 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
-import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
+import org.apache.ignite.internal.processors.platform.PlatformAsyncResult;
import org.apache.ignite.internal.processors.platform.PlatformContext;
import org.apache.ignite.internal.processors.platform.PlatformTarget;
import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.future.IgniteFutureImpl;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.plugin.PluginConfiguration;
import org.jetbrains.annotations.Nullable;
@@ -33,17 +36,20 @@ import org.jetbrains.annotations.Nullable;
* Test target.
*/
@SuppressWarnings("ConstantConditions")
-class PlatformTestPluginTarget extends PlatformAbstractTarget {
+class PlatformTestPluginTarget implements PlatformTarget {
/** */
private final String name;
+ /** */
+ private final PlatformContext platformCtx;
+
/**
* Constructor.
*
* @param platformCtx Context.
*/
PlatformTestPluginTarget(PlatformContext platformCtx, String name) {
- super(platformCtx);
+ this.platformCtx = platformCtx;
if (name == null) {
// Initialize from configuration.
@@ -65,12 +71,17 @@ class PlatformTestPluginTarget extends PlatformAbstractTarget {
return val + 1;
}
- /** {@inheritDoc} */
@Override public long processInStreamOutLong(int type, BinaryRawReaderEx reader) throws IgniteCheckedException {
return reader.readString().length();
}
/** {@inheritDoc} */
+ @Override public long processInStreamOutLong(int type, BinaryRawReaderEx reader, PlatformMemory mem)
+ throws IgniteCheckedException {
+ return processInStreamOutLong(type, reader);
+ }
+
+ /** {@inheritDoc} */
@Override public void processInStreamOutStream(int type, BinaryRawReaderEx reader, BinaryRawWriterEx writer)
throws IgniteCheckedException {
String s = reader.readString();
@@ -129,6 +140,76 @@ class PlatformTestPluginTarget extends PlatformAbstractTarget {
return new PlatformTestPluginTarget(platformCtx, name);
}
+ /** {@inheritDoc} */
+ @Override public PlatformAsyncResult processInStreamAsync(int type, BinaryRawReaderEx reader) throws IgniteCheckedException {
+ switch (type) {
+ case 1: {
+ // Async upper case.
+ final String val = reader.readString();
+ final GridFutureAdapter<String> fa = new GridFutureAdapter<>();
+
+ new Thread(new Runnable() {
+ @Override public void run() {
+ try {
+ Thread.sleep(500L);
+ fa.onDone(val.toUpperCase());
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }).start();
+
+ return new PlatformAsyncResult() {
+ @Override public IgniteFuture future() {
+ //noinspection unchecked
+ return new IgniteFutureImpl(fa);
+ }
+
+ @Override public void write(BinaryRawWriterEx writer, Object result) {
+ writer.writeString((String) result);
+ }
+ };
+ }
+ case 2: {
+ // Exception.
+ throw new PlatformTestPluginException("123");
+ }
+ case 3: {
+ // Async exception.
+ final GridFutureAdapter<String> fa = new GridFutureAdapter<>();
+
+ new Thread(new Runnable() {
+ @Override public void run() {
+ try {
+ Thread.sleep(500L);
+ fa.onDone(new PlatformTestPluginException("x"));
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }).start();
+
+ return new PlatformAsyncResult() {
+ @Override public IgniteFuture future() {
+ //noinspection unchecked
+ return new IgniteFutureImpl(fa);
+ }
+
+ @Override public void write(BinaryRawWriterEx writer, Object result) {
+ // No-op.
+ }
+ };
+ }
+ }
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Exception convertException(Exception e) {
+ return e;
+ }
+
/**
* Gets the plugin config.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/platforms/cpp/jni/include/ignite/jni/exports.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/include/ignite/jni/exports.h b/modules/platforms/cpp/jni/include/ignite/jni/exports.h
index a93f580..06be75d 100644
--- a/modules/platforms/cpp/jni/include/ignite/jni/exports.h
+++ b/modules/platforms/cpp/jni/include/ignite/jni/exports.h
@@ -66,6 +66,7 @@ extern "C" {
void* IGNITE_CALL IgniteTargetInObjectStreamOutObjectStream(gcj::JniContext* ctx, void* obj, int opType, void* arg, long long inMemPtr, long long outMemPtr);
void IGNITE_CALL IgniteTargetOutStream(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
void* IGNITE_CALL IgniteTargetOutObject(gcj::JniContext* ctx, void* obj, int opType);
+ void IGNITE_CALL IgniteTargetInStreamAsync(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
void IGNITE_CALL IgniteTargetListenFuture(gcj::JniContext* ctx, void* obj, long long futId, int typ);
void IGNITE_CALL IgniteTargetListenFutureForOperation(gcj::JniContext* ctx, void* obj, long long futId, int typ, int opId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/platforms/cpp/jni/include/ignite/jni/java.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/include/ignite/jni/java.h b/modules/platforms/cpp/jni/include/ignite/jni/java.h
index a07b844..7c5d684 100644
--- a/modules/platforms/cpp/jni/include/ignite/jni/java.h
+++ b/modules/platforms/cpp/jni/include/ignite/jni/java.h
@@ -208,6 +208,7 @@ namespace ignite
jmethodID m_PlatformTarget_inStreamOutObject;
jmethodID m_PlatformTarget_outStream;
jmethodID m_PlatformTarget_outObject;
+ jmethodID m_PlatformTarget_inStreamAsync;
jmethodID m_PlatformTarget_inStreamOutStream;
jmethodID m_PlatformTarget_inObjectStreamOutObjectStream;
jmethodID m_PlatformTarget_listenFuture;
@@ -387,6 +388,7 @@ namespace ignite
jobject TargetInObjectStreamOutObjectStream(jobject obj, int opType, void* arg, long long inMemPtr, long long outMemPtr, JniErrorInfo* errInfo = NULL);
void TargetOutStream(jobject obj, int opType, long long memPtr, JniErrorInfo* errInfo = NULL);
jobject TargetOutObject(jobject obj, int opType, JniErrorInfo* errInfo = NULL);
+ void TargetInStreamAsync(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
void TargetListenFuture(jobject obj, long long futId, int typ);
void TargetListenFutureForOperation(jobject obj, long long futId, int typ, int opId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/platforms/cpp/jni/project/vs/module.def
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/project/vs/module.def b/modules/platforms/cpp/jni/project/vs/module.def
index 45a5bff..8159f8d 100644
--- a/modules/platforms/cpp/jni/project/vs/module.def
+++ b/modules/platforms/cpp/jni/project/vs/module.def
@@ -23,6 +23,7 @@ IgniteTargetInObjectStreamOutObjectStream @21
IgniteTargetListenFuture @22
IgniteTargetListenFutureForOperation @23
IgniteTargetInLongOutLong @24
+IgniteTargetInStreamAsync @25
IgniteProcessorCompute @64
IgniteProcessorMessage @65
IgniteProcessorEvents @66
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/platforms/cpp/jni/src/exports.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/src/exports.cpp b/modules/platforms/cpp/jni/src/exports.cpp
index 17fed71..6c590e4 100644
--- a/modules/platforms/cpp/jni/src/exports.cpp
+++ b/modules/platforms/cpp/jni/src/exports.cpp
@@ -182,6 +182,10 @@ extern "C" {
return ctx->TargetOutObject(static_cast<jobject>(obj), opType);
}
+ void IGNITE_CALL IgniteTargetInStreamAsync(gcj::JniContext* ctx, void* obj, int opType, long long memPtr) {
+ ctx->TargetInStreamAsync(static_cast<jobject>(obj), opType, memPtr);
+ }
+
void IGNITE_CALL IgniteTargetListenFuture(gcj::JniContext* ctx, void* obj, long long futId, int typ) {
ctx->TargetListenFuture(static_cast<jobject>(obj), futId, typ);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/platforms/cpp/jni/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/src/java.cpp b/modules/platforms/cpp/jni/src/java.cpp
index 1988a86..004a99c 100644
--- a/modules/platforms/cpp/jni/src/java.cpp
+++ b/modules/platforms/cpp/jni/src/java.cpp
@@ -258,6 +258,7 @@ namespace ignite
JniMethod M_PLATFORM_TARGET_IN_OBJECT_STREAM_OUT_OBJECT_STREAM = JniMethod("inObjectStreamOutObjectStream", "(ILjava/lang/Object;JJ)Ljava/lang/Object;", false);
JniMethod M_PLATFORM_TARGET_OUT_STREAM = JniMethod("outStream", "(IJ)V", false);
JniMethod M_PLATFORM_TARGET_OUT_OBJECT = JniMethod("outObject", "(I)Ljava/lang/Object;", false);
+ JniMethod M_PLATFORM_TARGET_IN_STREAM_ASYNC = JniMethod("inStreamAsync", "(IJ)V", false);
JniMethod M_PLATFORM_TARGET_LISTEN_FUTURE = JniMethod("listenFuture", "(JI)V", false);
JniMethod M_PLATFORM_TARGET_LISTEN_FOR_OPERATION = JniMethod("listenFutureForOperation", "(JII)V", false);
@@ -590,6 +591,7 @@ namespace ignite
m_PlatformTarget_outObject = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_OUT_OBJECT);
m_PlatformTarget_inStreamOutStream = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_STREAM_OUT_STREAM);
m_PlatformTarget_inObjectStreamOutObjectStream = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_OBJECT_STREAM_OUT_OBJECT_STREAM);
+ m_PlatformTarget_inStreamAsync = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_STREAM_ASYNC);
m_PlatformTarget_listenFuture = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_LISTEN_FUTURE);
m_PlatformTarget_listenFutureForOperation = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_LISTEN_FOR_OPERATION);
@@ -1386,6 +1388,14 @@ namespace ignite
return LocalToGlobal(env, res);
}
+ void JniContext::TargetInStreamAsync(jobject obj, int opType, long long memPtr, JniErrorInfo* err) {
+ JNIEnv* env = Attach();
+
+ env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformTarget_inStreamAsync, opType, memPtr);
+
+ ExceptionCheck(env, err);
+ }
+
void JniContext::TargetListenFuture(jobject obj, long long futId, int typ) {
JNIEnv* env = Attach();
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs
index b6c00b5..8256bba 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Tests.Plugin
using System;
using System.Collections.Generic;
using System.IO;
+ using System.Linq;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Interop;
@@ -117,6 +118,22 @@ namespace Apache.Ignite.Core.Tests.Plugin
var resCopy = res.Item2.OutObject(1);
Assert.AreEqual("name1_abc", resCopy.OutStream(1, r => r.ReadString()));
+ // Async operation.
+ var task = target.DoOutOpAsync(1, w => w.WriteString("foo"), r => r.ReadString());
+ Assert.IsFalse(task.IsCompleted);
+ var asyncRes = task.Result;
+ Assert.IsTrue(task.IsCompleted);
+ Assert.AreEqual("FOO", asyncRes);
+
+ // Async operation with exception in entry point.
+ Assert.Throws<TestIgnitePluginException>(() => target.DoOutOpAsync<object>(2, null, null));
+
+ // Async operation with exception in future.
+ var errTask = target.DoOutOpAsync<object>(3, null, null);
+ Assert.IsFalse(errTask.IsCompleted);
+ var aex = Assert.Throws<AggregateException>(() => errTask.Wait());
+ Assert.IsInstanceOf<IgniteException>(aex.InnerExceptions.Single());
+
// Throws custom mapped exception.
var ex = Assert.Throws<TestIgnitePluginException>(() => target.InLongOutLong(-1, 0));
Assert.AreEqual("Baz", ex.Message);
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
index f115042..621bfa5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
@@ -962,6 +962,35 @@ namespace Apache.Ignite.Core.Impl
return GetPlatformTarget(DoOutOpObject(type));
}
+ /** <inheritdoc /> */
+ public Task<T> DoOutOpAsync<T>(int type, Action<IBinaryRawWriter> writeAction = null,
+ Func<IBinaryRawReader, T> readAction = null)
+ {
+ var convertFunc = readAction != null
+ ? r => readAction(r)
+ : (Func<BinaryReader, T>) null;
+
+ return GetFuture((futId, futType) =>
+ {
+ using (var stream = IgniteManager.Memory.Allocate().GetStream())
+ {
+ stream.WriteLong(futId);
+ stream.WriteInt(futType);
+
+ if (writeAction != null)
+ {
+ var writer = _marsh.StartMarshal(stream);
+
+ writeAction(writer);
+
+ FinishMarshal(writer);
+ }
+
+ UU.TargetInStreamAsync(_target, type, stream.SynchronizeOutput());
+ }
+ }, false, convertFunc).Task;
+ }
+
/// <summary>
/// Gets the platform target.
/// </summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
index a6a3a31..289589f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
@@ -149,6 +149,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetOutObject")]
public static extern void* TargetOutObject(void* ctx, void* target, int opType);
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetInStreamAsync")]
+ public static extern void TargetInStreamAsync(void* ctx, void* target, int opType, long memPtr);
+
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAcquire")]
public static extern void* Acquire(void* ctx, void* target);
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
index 90e5230..986972f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -464,6 +464,11 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
return target.ChangeTarget(res);
}
+ internal static void TargetInStreamAsync(IUnmanagedTarget target, int opType, long memPtr)
+ {
+ JNI.TargetInStreamAsync(target.Context, target.Target, opType, memPtr);
+ }
+
#endregion
#region NATIVE METHODS: MISCELANNEOUS
http://git-wip-us.apache.org/repos/asf/ignite/blob/637c18de/modules/platforms/dotnet/Apache.Ignite.Core/Interop/IPlatformTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Interop/IPlatformTarget.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Interop/IPlatformTarget.cs
index 8b8963f..e8f8bfb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Interop/IPlatformTarget.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Interop/IPlatformTarget.cs
@@ -18,7 +18,9 @@
namespace Apache.Ignite.Core.Interop
{
using System;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
/// <summary>
/// Interface to interoperate with
@@ -87,5 +89,16 @@ namespace Apache.Ignite.Core.Interop
/// <param name="type">Operation type code.</param>
/// <returns>Result.</returns>
IPlatformTarget OutObject(int type);
+
+ /// <summary>
+ /// Performs asynchronous operation.
+ /// </summary>
+ /// <typeparam name="T">Result type</typeparam>
+ /// <param name="type">Operation type code.</param>
+ /// <param name="writeAction">Write action (can be null).</param>
+ /// <param name="readAction">Read function (can be null).</param>
+ /// <returns>Task.</returns>
+ Task<T> DoOutOpAsync<T>(int type, Action<IBinaryRawWriter> writeAction,
+ Func<IBinaryRawReader, T> readAction);
}
}
[04/16] ignite git commit: IGNITE-4825 Inject resources from platform
plugins
Posted by vo...@apache.org.
IGNITE-4825 Inject resources from platform plugins
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4820c458
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4820c458
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4820c458
Branch: refs/heads/ignite-4565-ddl
Commit: 4820c458fde5d641c114b2fda94061abe452a2d0
Parents: 8e5e3cb
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Wed Mar 15 17:41:41 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Wed Mar 15 17:41:41 2017 +0300
----------------------------------------------------------------------
.../Plugin/PluginTest.cs | 24 ++++++++++++++++++++
.../Impl/Plugin/PluginContext.cs | 9 ++++++++
.../Apache.Ignite.Core/Plugin/IPluginContext.cs | 8 +++++++
3 files changed, 41 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4820c458/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs
index 8256bba..7e766a0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs
@@ -25,6 +25,7 @@ namespace Apache.Ignite.Core.Tests.Plugin
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Interop;
using Apache.Ignite.Core.Plugin;
+ using Apache.Ignite.Core.Resource;
using NUnit.Framework;
/// <summary>
@@ -67,6 +68,7 @@ namespace Apache.Ignite.Core.Tests.Plugin
Assert.IsNotNull(ctx.Ignite);
Assert.AreEqual(cfg, ctx.IgniteConfiguration);
Assert.AreEqual("barbaz", ctx.PluginConfiguration.PluginProperty);
+ CheckResourceInjection(ctx);
var plugin2 = ignite.GetPlugin<TestIgnitePlugin>(TestIgnitePluginProvider.PluginName);
Assert.AreEqual(plugin, plugin2);
@@ -82,6 +84,21 @@ namespace Apache.Ignite.Core.Tests.Plugin
}
/// <summary>
+ /// Checks the resource injection.
+ /// </summary>
+ private static void CheckResourceInjection(IPluginContext<TestIgnitePluginConfiguration> ctx)
+ {
+ var obj = new Injectee();
+
+ Assert.IsNull(obj.Ignite);
+
+ ctx.InjectResources(obj);
+
+ Assert.IsNotNull(obj.Ignite);
+ Assert.AreEqual(ctx.Ignite.Name, obj.Ignite.Name);
+ }
+
+ /// <summary>
/// Checks the plugin target operations.
/// </summary>
private static void CheckPluginTarget(IPlatformTarget target, string expectedName,
@@ -314,5 +331,12 @@ namespace Apache.Ignite.Core.Tests.Plugin
PluginLog.Add(Name + ".Start");
}
}
+
+ private class Injectee
+ {
+ [InstanceResource]
+ // ReSharper disable once UnusedAutoPropertyAccessor.Local
+ public IIgnite Ignite { get; set; }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4820c458/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Plugin/PluginContext.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Plugin/PluginContext.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Plugin/PluginContext.cs
index fd7033c..cc20cb3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Plugin/PluginContext.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Plugin/PluginContext.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Plugin
{
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Common;
+ using Apache.Ignite.Core.Impl.Resource;
using Apache.Ignite.Core.Impl.Unmanaged;
using Apache.Ignite.Core.Interop;
using Apache.Ignite.Core.Plugin;
@@ -87,5 +88,13 @@ namespace Apache.Ignite.Core.Impl.Plugin
_pluginProcessor.RegisterCallback(callbackId, callback);
}
+
+ /** <inheritdoc /> */
+ public void InjectResources(object target)
+ {
+ IgniteArgumentCheck.NotNull(target, "target");
+
+ ResourceProcessor.Inject(target, _pluginProcessor.Ignite);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4820c458/modules/platforms/dotnet/Apache.Ignite.Core/Plugin/IPluginContext.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Plugin/IPluginContext.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Plugin/IPluginContext.cs
index 03d130b..9349611 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Plugin/IPluginContext.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Plugin/IPluginContext.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Plugin
{
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Interop;
+ using Apache.Ignite.Core.Resource;
/// <summary>
/// Plugin execution context.
@@ -64,5 +65,12 @@ namespace Apache.Ignite.Core.Plugin
/// <param name="callbackId">Callback id.</param>
/// <param name="callback">Callback delegate.</param>
void RegisterCallback(long callbackId, PluginCallback callback);
+
+ /// <summary>
+ /// Injects resources into specified target:
+ /// populates members marked with <see cref="InstanceResourceAttribute"/>.
+ /// </summary>
+ /// <param name="target">Target object.</param>
+ void InjectResources(object target);
}
}
\ No newline at end of file
[09/16] ignite git commit: Internal cache API cleanup.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 f5687a0..307c348 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
@@ -17,21 +17,8 @@
package org.apache.ignite.internal.processors.cache.transactions;
-import java.util.Collection;
-import java.util.Map;
-import javax.cache.Cache;
-import javax.cache.expiry.ExpiryPolicy;
-import javax.cache.processor.EntryProcessor;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
-import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.GridCacheReturn;
-import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.util.lang.GridInClosure3;
import org.jetbrains.annotations.Nullable;
/**
@@ -59,141 +46,11 @@ public interface IgniteTxLocalEx extends IgniteInternalTx {
public void userRollback() throws IgniteCheckedException;
/**
- * @param cacheCtx Cache context.
- * @param keys Keys to get.
- * @param deserializeBinary Deserialize binary flag.
- * @param skipVals Skip values flag.
- * @param keepCacheObjects Keep cache objects
- * @param skipStore Skip store flag.
- * @return Future for this get.
- */
- public <K, V> IgniteInternalFuture<Map<K, V>> getAllAsync(
- GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- Collection<KeyCacheObject> keys,
- boolean deserializeBinary,
- boolean skipVals,
- boolean keepCacheObjects,
- boolean skipStore,
- boolean needVer);
-
- /**
- * @param cacheCtx Cache context.
- * @param map Map to put.
- * @param retval Flag indicating whether a value should be returned.
- * @return Future for put operation.
- */
- public <K, V> IgniteInternalFuture<GridCacheReturn> putAllAsync(
- GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- Map<? extends K, ? extends V> map,
- boolean retval);
-
- /**
- * @param cacheCtx Cache context.
- * @param key Key.
- * @param val Value.
- * @param retval Return value flag.
- * @param filter Filter.
- * @return Future for put operation.
- */
- public <K, V> IgniteInternalFuture<GridCacheReturn> putAsync(
- GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- K key,
- V val,
- boolean retval,
- CacheEntryPredicate filter);
-
- /**
- * @param cacheCtx Cache context.
- * @param key Key.
- * @param entryProcessor Entry processor.
- * @param invokeArgs Optional arguments for entry processor.
- * @return Operation future.
- */
- public <K, V> IgniteInternalFuture<GridCacheReturn> invokeAsync(
- GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- K key,
- EntryProcessor<K, V, Object> entryProcessor,
- Object... invokeArgs);
-
- /**
- * @param cacheCtx Cache context.
- * @param map Entry processors map.
- * @param invokeArgs Optional arguments for entry processor.
- * @return Operation future.
- */
- public <K, V, T> IgniteInternalFuture<GridCacheReturn> invokeAsync(
- GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- Map<? extends K, ? extends EntryProcessor<K, V, Object>> map,
- Object... invokeArgs);
-
- /**
- * @param cacheCtx Cache context.
- * @param keys Keys to remove.
- * @param retval Flag indicating whether a value should be returned.
- * @param filter Filter.
- * @param singleRmv {@code True} for single key remove operation ({@link Cache#remove(Object)}.
- * @return Future for asynchronous remove.
- */
- public <K, V> IgniteInternalFuture<GridCacheReturn> removeAllAsync(
- GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- Collection<? extends K> keys,
- boolean retval,
- CacheEntryPredicate filter,
- boolean singleRmv);
-
- /**
- * @param cacheCtx Cache context.
- * @param drMap DR map to put.
- * @return Future for DR put operation.
- */
- public IgniteInternalFuture<?> putAllDrAsync(
- GridCacheContext cacheCtx,
- Map<KeyCacheObject, GridCacheDrInfo> drMap);
-
- /**
- * @param cacheCtx Cache context.
- * @param drMap DR map.
- * @return Future for asynchronous remove.
- */
- public IgniteInternalFuture<?> removeAllDrAsync(
- GridCacheContext cacheCtx,
- Map<KeyCacheObject, GridCacheVersion> drMap);
-
- /**
* Finishes transaction (either commit or rollback).
*
* @param commit {@code True} if commit, {@code false} if rollback.
* @return {@code True} if state has been changed.
* @throws IgniteCheckedException If finish failed.
*/
- public boolean finish(boolean commit) throws IgniteCheckedException;
-
- /**
- * @param cacheCtx Cache context.
- * @param readThrough Read through flag.
- * @param async if {@code True}, then loading will happen in a separate thread.
- * @param keys Keys.
- * @param skipVals Skip values flag.
- * @param needVer If {@code true} version is required for loaded values.
- * @param c Closure to be applied for loaded values.
- * @param expiryPlc Expiry policy.
- * @return Future with {@code True} value if loading took place.
- */
- public IgniteInternalFuture<Void> loadMissing(
- GridCacheContext cacheCtx,
- AffinityTopologyVersion topVer,
- boolean readThrough,
- boolean async,
- Collection<KeyCacheObject> keys,
- boolean skipVals,
- boolean needVer,
- boolean keepBinary,
- final ExpiryPolicy expiryPlc,
- GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c);
+ public boolean localFinish(boolean commit) throws IgniteCheckedException;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 df3bad2..d1334ef 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
@@ -56,7 +56,6 @@ import org.apache.ignite.internal.processors.cache.distributed.GridCacheMappedVe
import org.apache.ignite.internal.processors.cache.distributed.GridCacheTxFinishSync;
import org.apache.ignite.internal.processors.cache.distributed.GridCacheTxRecoveryFuture;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockCancelledException;
-import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxRemoteAdapter;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocal;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxOnePhaseCommitAckRequest;
@@ -82,7 +81,6 @@ import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.transactions.TransactionConcurrency;
@@ -127,7 +125,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
/** Slow tx warn timeout (initialized to 0). */
private static final int SLOW_TX_WARN_TIMEOUT = Integer.getInteger(IGNITE_SLOW_TX_WARN_TIMEOUT, 0);
- /** Tx salvage timeout (default 3s). */
+ /** Tx salvage timeout. */
private static final int TX_SALVAGE_TIMEOUT = Integer.getInteger(IGNITE_TX_SALVAGE_TIMEOUT, 100);
/** One phase commit deferred ack request timeout. */
@@ -138,9 +136,6 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
private static final int DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_BUFFER_SIZE =
Integer.getInteger(IGNITE_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_BUFFER_SIZE, 256);
- /** Version in which deadlock detection introduced. */
- public static final IgniteProductVersion TX_DEADLOCK_DETECTION_SINCE = IgniteProductVersion.fromString("1.5.19");
-
/** Deadlock detection maximum iterations. */
static int DEADLOCK_MAX_ITERS =
IgniteSystemProperties.getInteger(IGNITE_TX_DEADLOCK_DETECTION_MAX_ITERS, 1000);
@@ -184,7 +179,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
PER_SEGMENT_Q);
/** Pending one phase commit ack requests sender. */
- private GridDeferredAckMessageSender deferredAckMessageSender;
+ private GridDeferredAckMessageSender deferredAckMsgSnd;
/** Transaction finish synchronizer. */
private GridCacheTxFinishSync txFinishSync;
@@ -206,54 +201,6 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
private TxDeadlockDetection txDeadlockDetection;
/** {@inheritDoc} */
- @Override protected void onKernalStart0(boolean reconnect) {
- if (reconnect)
- return;
-
- cctx.gridEvents().addLocalEventListener(
- new GridLocalEventListener() {
- @Override public void onEvent(Event evt) {
- assert evt instanceof DiscoveryEvent;
- assert evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT;
-
- DiscoveryEvent discoEvt = (DiscoveryEvent)evt;
-
- UUID nodeId = discoEvt.eventNode().id();
-
- cctx.time().addTimeoutObject(new NodeFailureTimeoutObject(nodeId));
-
- if (txFinishSync != null)
- txFinishSync.onNodeLeft(nodeId);
-
- for (TxDeadlockFuture fut : deadlockDetectFuts.values())
- fut.onNodeLeft(nodeId);
-
- for (Map.Entry<GridCacheVersion, Object> entry : completedVersHashMap.entrySet()) {
- Object obj = entry.getValue();
-
- if (obj instanceof GridCacheReturnCompletableWrapper &&
- nodeId.equals(((GridCacheReturnCompletableWrapper)obj).nodeId()))
- removeTxReturn(entry.getKey());
- }
- }
- },
- EVT_NODE_FAILED, EVT_NODE_LEFT);
-
- this.txDeadlockDetection = new TxDeadlockDetection(cctx);
-
- cctx.gridIO().addMessageListener(TOPIC_TX, new DeadlockDetectionListener());
-
- for (IgniteInternalTx tx : idMap.values()) {
- if ((!tx.local() || tx.dht()) && !cctx.discovery().aliveAll(tx.masterNodeIds())) {
- if (log.isDebugEnabled())
- log.debug("Remaining transaction from left node: " + tx);
-
- salvageTx(tx, true, USER_FINISH);
- }
- }
- }
-
- /** {@inheritDoc} */
@Override protected void onKernalStop0(boolean cancel) {
cctx.gridIO().removeMessageListener(TOPIC_TX);
}
@@ -264,7 +211,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
txHnd = new IgniteTxHandler(cctx);
- deferredAckMessageSender = new GridDeferredAckMessageSender(cctx.time(), cctx.kernalContext().closure()) {
+ deferredAckMsgSnd = new GridDeferredAckMessageSender(cctx.time(), cctx.kernalContext().closure()) {
@Override public int getTimeout() {
return DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUT;
}
@@ -293,6 +240,40 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
}
}
};
+
+ cctx.gridEvents().addLocalEventListener(
+ new GridLocalEventListener() {
+ @Override public void onEvent(Event evt) {
+ assert evt instanceof DiscoveryEvent;
+ assert evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT;
+
+ DiscoveryEvent discoEvt = (DiscoveryEvent)evt;
+
+ UUID nodeId = discoEvt.eventNode().id();
+
+ // Wait some time in case there are some unprocessed messages from failed node.
+ cctx.time().addTimeoutObject(new NodeFailureTimeoutObject(nodeId));
+
+ if (txFinishSync != null)
+ txFinishSync.onNodeLeft(nodeId);
+
+ for (TxDeadlockFuture fut : deadlockDetectFuts.values())
+ fut.onNodeLeft(nodeId);
+
+ for (Map.Entry<GridCacheVersion, Object> entry : completedVersHashMap.entrySet()) {
+ Object obj = entry.getValue();
+
+ if (obj instanceof GridCacheReturnCompletableWrapper &&
+ nodeId.equals(((GridCacheReturnCompletableWrapper)obj).nodeId()))
+ removeTxReturn(entry.getKey());
+ }
+ }
+ },
+ EVT_NODE_FAILED, EVT_NODE_LEFT);
+
+ this.txDeadlockDetection = new TxDeadlockDetection(cctx);
+
+ cctx.gridIO().addMessageListener(TOPIC_TX, new DeadlockDetectionListener());
}
/** {@inheritDoc} */
@@ -320,85 +301,35 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
* Invalidates transaction.
*
* @param tx Transaction.
- * @return {@code True} if transaction was salvaged by this call.
*/
- public boolean salvageTx(IgniteInternalTx tx) {
- return salvageTx(tx, false, USER_FINISH);
+ public void salvageTx(IgniteInternalTx tx) {
+ salvageTx(tx, USER_FINISH);
}
/**
* Invalidates transaction.
*
* @param tx Transaction.
- * @param warn {@code True} if warning should be logged.
* @param status Finalization status.
- * @return {@code True} if transaction was salvaged by this call.
*/
- private boolean salvageTx(IgniteInternalTx tx, boolean warn, IgniteInternalTx.FinalizationStatus status) {
+ private void salvageTx(IgniteInternalTx tx, IgniteInternalTx.FinalizationStatus status) {
assert tx != null;
TransactionState state = tx.state();
- if (state == ACTIVE || state == PREPARING || state == PREPARED) {
- try {
- if (!tx.markFinalizing(status)) {
- if (log.isDebugEnabled())
- log.debug("Will not try to commit invalidate transaction (could not mark finalized): " + tx);
-
- return false;
- }
-
- tx.systemInvalidate(true);
-
- tx.prepare();
-
- if (tx.state() == PREPARING) {
- if (log.isDebugEnabled())
- log.debug("Ignoring transaction in PREPARING state as it is currently handled " +
- "by another thread: " + tx);
-
- return false;
- }
-
- if (tx instanceof IgniteTxRemoteEx) {
- IgniteTxRemoteEx rmtTx = (IgniteTxRemoteEx)tx;
-
- rmtTx.doneRemote(tx.xidVersion(), Collections.<GridCacheVersion>emptyList(),
- Collections.<GridCacheVersion>emptyList(), Collections.<GridCacheVersion>emptyList());
- }
-
- tx.commit();
-
- if (warn) {
- // This print out cannot print any peer-deployed entity either
- // directly or indirectly.
- U.warn(log, "Invalidated transaction because originating node either " +
- "crashed or left grid: " + CU.txString(tx));
- }
- }
- catch (IgniteCheckedException ignore) {
+ if (state == ACTIVE || state == PREPARING || state == PREPARED || state == MARKED_ROLLBACK) {
+ if (!tx.markFinalizing(status)) {
if (log.isDebugEnabled())
- log.debug("Optimistic failure while invalidating transaction (will rollback): " +
- tx.xidVersion());
+ log.debug("Will not try to commit invalidate transaction (could not mark finalized): " + tx);
- try {
- tx.rollback();
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to rollback transaction: " + tx.xidVersion(), e);
- }
- }
- }
- else if (state == MARKED_ROLLBACK) {
- try {
- tx.rollback();
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to rollback transaction: " + tx.xidVersion(), e);
+ return;
}
- }
- return true;
+ tx.salvageTx();
+
+ if (log.isDebugEnabled())
+ log.debug("Invalidated transaction because originating node left grid: " + CU.txString(tx));
+ }
}
/**
@@ -442,7 +373,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
* @return {@code True} if transaction has been committed or rolled back,
* {@code false} otherwise.
*/
- public boolean isCompleted(IgniteInternalTx tx) {
+ private boolean isCompleted(IgniteInternalTx tx) {
boolean completed = completedVersHashMap.containsKey(tx.xidVersion());
// Need check that for tx with timeout rollback message was not received before lock.
@@ -461,7 +392,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
* @param txSize Expected transaction size.
* @return New transaction.
*/
- public IgniteTxLocalAdapter newTx(
+ public GridNearTxLocal newTx(
boolean implicit,
boolean implicitSingle,
@Nullable GridCacheContext sysCacheCtx,
@@ -672,13 +603,19 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
}
/**
+ * @param cctx Cache context.
* @return Transaction for current thread.
*/
- @SuppressWarnings({"unchecked"})
- public <T> T threadLocalTx(GridCacheContext cctx) {
+ public GridNearTxLocal threadLocalTx(GridCacheContext cctx) {
IgniteInternalTx tx = tx(cctx, Thread.currentThread().getId());
- return tx != null && tx.local() && (!tx.dht() || tx.colocated()) && !tx.implicit() ? (T)tx : null;
+ if (tx != null && tx.local() && (!tx.dht() || tx.colocated()) && !tx.implicit()) {
+ assert tx instanceof GridNearTxLocal : tx;
+
+ return (GridNearTxLocal)tx;
+ }
+
+ return null;
}
/**
@@ -747,48 +684,53 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
* @return Local transaction.
*/
@Nullable public IgniteInternalTx localTxx() {
- IgniteInternalTx tx = txx();
+ IgniteInternalTx tx = tx();
return tx != null && tx.local() ? tx : null;
}
/**
- * @return Transaction for current thread.
- */
- @SuppressWarnings({"unchecked"})
- public IgniteInternalTx txx() {
- return tx();
- }
-
- /**
* @return User transaction for current thread.
*/
- @Nullable public IgniteInternalTx userTx() {
+ @Nullable public GridNearTxLocal userTx() {
IgniteInternalTx tx = txContext();
- if (tx != null && tx.user() && tx.state() == ACTIVE)
- return tx;
+ if (activeUserTx(tx))
+ return (GridNearTxLocal)tx;
tx = tx(null, Thread.currentThread().getId());
- return tx != null && tx.user() && tx.state() == ACTIVE ? tx : null;
+ if (activeUserTx(tx))
+ return (GridNearTxLocal)tx;
+
+ return null;
}
/**
+ * @param cctx Cache context.
* @return User transaction for current thread.
*/
- @Nullable public IgniteInternalTx userTx(GridCacheContext cctx) {
+ @Nullable GridNearTxLocal userTx(GridCacheContext cctx) {
IgniteInternalTx tx = tx(cctx, Thread.currentThread().getId());
- return tx != null && tx.user() && tx.state() == ACTIVE ? tx : null;
+ if (activeUserTx(tx))
+ return (GridNearTxLocal)tx;
+
+ return null;
}
/**
- * @return User transaction.
+ * @param tx Transaction.
+ * @return {@code True} if given transaction is explicitly started user transaction.
*/
- @SuppressWarnings({"unchecked"})
- @Nullable public <T extends IgniteTxLocalEx> T userTxx() {
- return (T)userTx();
+ private boolean activeUserTx(@Nullable IgniteInternalTx tx) {
+ if (tx != null && tx.user() && tx.state() == ACTIVE) {
+ assert tx instanceof GridNearTxLocal : tx;
+
+ return true;
+ }
+
+ return false;
}
/**
@@ -1241,7 +1183,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
unlockMultiple(tx, tx.readEntries());
// 6. Notify evictions.
- notifyEvitions(tx);
+ notifyEvictions(tx);
// 7. Remove obsolete entries from cache.
removeObsolete(tx);
@@ -1314,7 +1256,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
unlockMultiple(tx, tx.readEntries());
// 4. Notify evictions.
- notifyEvitions(tx);
+ notifyEvictions(tx);
// 5. Remove obsolete entries.
removeObsolete(tx);
@@ -1364,7 +1306,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
if (txIdMap.remove(tx.xidVersion(), tx)) {
// 1. Notify evictions.
- notifyEvitions(tx);
+ notifyEvictions(tx);
// 2. Evict near entries.
if (!tx.readMap().isEmpty()) {
@@ -1400,7 +1342,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
*
* @param tx Tx to uncommit.
*/
- public void uncommitTx(IgniteInternalTx tx) {
+ void uncommitTx(IgniteInternalTx tx) {
assert tx != null;
if (log.isDebugEnabled())
@@ -1417,15 +1359,16 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
unlockMultiple(tx, tx.readEntries());
// 3. Notify evictions.
- notifyEvitions(tx);
+ notifyEvictions(tx);
// 4. Remove from per-thread storage.
clearThreadMap(tx);
// 5. Unregister explicit locks.
- if (!tx.alternateVersions().isEmpty())
+ if (!tx.alternateVersions().isEmpty()) {
for (GridCacheVersion ver : tx.alternateVersions())
idMap.remove(ver);
+ }
// 6. Remove Near-2-DHT mappings.
if (tx instanceof GridCacheMappedVersion)
@@ -1481,7 +1424,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
/**
* @param tx Transaction to notify evictions for.
*/
- private void notifyEvitions(IgniteInternalTx tx) {
+ private void notifyEvictions(IgniteInternalTx tx) {
if (tx.internal())
return;
@@ -1981,10 +1924,12 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
return;
}
- if (tx instanceof GridDistributedTxRemoteAdapter) {
+ if (tx instanceof IgniteTxRemoteEx) {
IgniteTxRemoteEx rmtTx = (IgniteTxRemoteEx)tx;
- rmtTx.doneRemote(tx.xidVersion(), Collections.<GridCacheVersion>emptyList(), Collections.<GridCacheVersion>emptyList(),
+ rmtTx.doneRemote(tx.xidVersion(),
+ Collections.<GridCacheVersion>emptyList(),
+ Collections.<GridCacheVersion>emptyList(),
Collections.<GridCacheVersion>emptyList());
}
@@ -2058,43 +2003,27 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
return;
}
- if (supportsDeadlockDetection(node)) {
- TxLocksRequest req = new TxLocksRequest(fut.futureId(), txKeys);
+ TxLocksRequest req = new TxLocksRequest(fut.futureId(), txKeys);
- try {
- if (!cctx.localNodeId().equals(nodeId))
- req.prepareMarshal(cctx);
-
- cctx.gridIO().sendToGridTopic(node, TOPIC_TX, req, SYSTEM_POOL);
- }
- catch (IgniteCheckedException e) {
- if (e instanceof ClusterTopologyCheckedException) {
- if (log.isDebugEnabled())
- log.debug("Failed to finish deadlock detection, node left: " + nodeId);
- }
- else
- U.warn(log, "Failed to finish deadlock detection: " + e, e);
+ try {
+ if (!cctx.localNodeId().equals(nodeId))
+ req.prepareMarshal(cctx);
- fut.onDone();
- }
+ cctx.gridIO().sendToGridTopic(node, TOPIC_TX, req, SYSTEM_POOL);
}
- else {
- if (log.isDebugEnabled())
- log.debug("Failed to finish deadlock detection, node does not support deadlock detection: " + node);
+ catch (IgniteCheckedException e) {
+ if (e instanceof ClusterTopologyCheckedException) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to finish deadlock detection, node left: " + nodeId);
+ }
+ else
+ U.warn(log, "Failed to finish deadlock detection: " + e, e);
fut.onDone();
}
}
/**
- * @param node Node.
- * @return {@code True} if node supports deadlock detection protocol.
- */
- private boolean supportsDeadlockDetection(ClusterNode node) {
- return TX_DEADLOCK_DETECTION_SINCE.compareToIgnoreTimestamp(node.version()) <= 0;
- }
-
- /**
* @param tx Tx.
* @param txKeys Tx keys.
* @return {@code True} if key is involved into tx.
@@ -2265,7 +2194,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
* @param ver Version to ack.
*/
public void sendDeferredAckResponse(UUID nodeId, GridCacheVersion ver) {
- deferredAckMessageSender.sendDeferredAckMessage(nodeId, ver);
+ deferredAckMsgSnd.sendDeferredAckMessage(nodeId, ver);
}
/**
@@ -2314,9 +2243,9 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
", failedNodeId=" + evtNodeId + ']');
for (final IgniteInternalTx tx : txs()) {
- if ((tx.near() && !tx.local()) || (tx.storeUsed() && tx.masterNodeIds().contains(evtNodeId))) {
+ if ((tx.near() && !tx.local()) || (tx.storeWriteThrough() && tx.masterNodeIds().contains(evtNodeId))) {
// Invalidate transactions.
- salvageTx(tx, false, RECOVERY_FINISH);
+ salvageTx(tx, RECOVERY_FINISH);
}
else {
// Check prepare only if originating node ID failed. Otherwise parent node will finish this tx.
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteEx.java
index 8ceca3f..87cc7cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteEx.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.cache.transactions;
import java.util.Collection;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
/**
@@ -25,6 +26,16 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
*/
public interface IgniteTxRemoteEx extends IgniteInternalTx {
/**
+ * @throws IgniteCheckedException If failed.
+ */
+ public void commitRemoteTx() throws IgniteCheckedException;
+
+ /**
+ *
+ */
+ public void rollbackRemoteTx();
+
+ /**
* @param baseVer Base version.
* @param committedVers Committed version.
* @param rolledbackVers Rolled back version.
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateAdapter.java
index 1c2ccbe..3c27bad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteStateAdapter.java
@@ -88,7 +88,7 @@ public abstract class IgniteTxRemoteStateAdapter implements IgniteTxRemoteState
}
/** {@inheritDoc} */
- @Override public boolean storeUsed(GridCacheSharedContext cctx) {
+ @Override public boolean storeWriteThrough(GridCacheSharedContext cctx) {
return false;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxState.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxState.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxState.java
index c121b1b..822e44e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxState.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxState.java
@@ -104,7 +104,7 @@ public interface IgniteTxState {
* @return {@code True} if transaction is allowed to use store and transactions spans one or more caches with
* store enabled.
*/
- public boolean storeUsed(GridCacheSharedContext cctx);
+ public boolean storeWriteThrough(GridCacheSharedContext cctx);
/**
* @param cctx Context.
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
index 76751de..399eea3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
@@ -289,14 +289,14 @@ public class IgniteTxStateImpl extends IgniteTxLocalStateAdapter {
}
/** {@inheritDoc} */
- @Override public boolean storeUsed(GridCacheSharedContext cctx) {
+ @Override public boolean storeWriteThrough(GridCacheSharedContext cctx) {
if (!activeCacheIds.isEmpty()) {
for (int i = 0; i < activeCacheIds.size(); i++) {
int cacheId = (int)activeCacheIds.get(i);
CacheStoreManager store = cctx.cacheContext(cacheId).store();
- if (store.configured())
+ if (store.configured() && store.isWriteThrough())
return true;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionProxyImpl.java
index 6134b9f..8ffec00 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionProxyImpl.java
@@ -26,6 +26,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteClientDisconnectedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -51,7 +52,7 @@ public class TransactionProxyImpl<K, V> implements TransactionProxy, Externaliza
/** Wrapped transaction. */
@GridToStringInclude
- private IgniteInternalTx tx;
+ private GridNearTxLocal tx;
/** Gateway. */
@GridToStringExclude
@@ -75,7 +76,7 @@ public class TransactionProxyImpl<K, V> implements TransactionProxy, Externaliza
* @param cctx Shared context.
* @param async Async flag.
*/
- public TransactionProxyImpl(IgniteInternalTx tx, GridCacheSharedContext<K, V> cctx, boolean async) {
+ public TransactionProxyImpl(GridNearTxLocal tx, GridCacheSharedContext<K, V> cctx, boolean async) {
assert tx != null;
assert cctx != null;
@@ -87,7 +88,7 @@ public class TransactionProxyImpl<K, V> implements TransactionProxy, Externaliza
/**
* @return Transaction.
*/
- public IgniteInternalTx tx() {
+ public GridNearTxLocal tx() {
return tx;
}
@@ -316,7 +317,9 @@ public class TransactionProxyImpl<K, V> implements TransactionProxy, Externaliza
private void saveFuture(IgniteInternalFuture<IgniteInternalTx> fut) {
IgniteInternalFuture<Transaction> fut0 = fut.chain(new CX1<IgniteInternalFuture<IgniteInternalTx>, Transaction>() {
@Override public Transaction applyx(IgniteInternalFuture<IgniteInternalTx> fut) throws IgniteCheckedException {
- return fut.get().proxy();
+ fut.get();
+
+ return TransactionProxyImpl.this;
}
});
@@ -330,7 +333,7 @@ public class TransactionProxyImpl<K, V> implements TransactionProxy, Externaliza
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- tx = (IgniteInternalTx)in.readObject();
+ tx = (GridNearTxLocal)in.readObject();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index 96644a3..0420182 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -67,7 +67,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheInternal;
import org.apache.ignite.internal.processors.cache.GridCacheUtils;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.lang.IgniteClosureX;
import org.apache.ignite.internal.util.lang.IgniteInClosureX;
import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
@@ -95,8 +95,8 @@ import static org.apache.ignite.internal.processors.datastructures.DataStructure
import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DataStructureType.ATOMIC_STAMPED;
import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DataStructureType.COUNT_DOWN_LATCH;
import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DataStructureType.QUEUE;
-import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DataStructureType.SEMAPHORE;
import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DataStructureType.REENTRANT_LOCK;
+import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DataStructureType.SEMAPHORE;
import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.DataStructureType.SET;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
@@ -342,7 +342,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
dsCacheCtx.gate().enter();
- try (IgniteInternalTx tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicSequenceValue seqVal = cast(dsView.get(key), GridCacheAtomicSequenceValue.class);
// Check that sequence hasn't been created in other thread yet.
@@ -471,7 +471,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
dsCacheCtx.gate().enter();
- try (IgniteInternalTx tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicLongValue val = cast(dsView.get(key), GridCacheAtomicLongValue.class);
// Check that atomic long hasn't been created in other thread yet.
@@ -551,7 +551,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
if (!create)
return c.applyx();
- try (IgniteInternalTx tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
IgniteCheckedException err =
utilityCache.invoke(DATA_STRUCTURES_KEY, new AddAtomicProcessor(dsInfo)).get();
@@ -623,7 +623,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
retryTopologySafe(new IgniteOutClosureX<Void>() {
@Override public Void applyx() throws IgniteCheckedException {
- try (IgniteInternalTx tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
T2<Boolean, IgniteCheckedException> res =
utilityCache.invoke(DATA_STRUCTURES_KEY, new RemoveDataStructureProcessor(dsInfo)).get();
@@ -682,7 +682,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
dsCacheCtx.gate().enter();
- try (IgniteInternalTx tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicReferenceValue val = cast(dsView.get(key),
GridCacheAtomicReferenceValue.class);
@@ -786,7 +786,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
dsCacheCtx.gate().enter();
- try (IgniteInternalTx tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicStampedValue val = cast(dsView.get(key),
GridCacheAtomicStampedValue.class);
@@ -1033,7 +1033,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
return retryTopologySafe(new IgniteOutClosureX<T>() {
@Override public T applyx() throws IgniteCheckedException {
- try (IgniteInternalTx tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
T2<String, IgniteCheckedException> res =
utilityCache.invoke(DATA_STRUCTURES_KEY, new AddCollectionProcessor(dsInfo)).get();
@@ -1133,7 +1133,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
dsCacheCtx.gate().enter();
- try (IgniteInternalTx tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheCountDownLatchValue val = cast(dsView.get(key), GridCacheCountDownLatchValue.class);
// Check that count down hasn't been created in other thread yet.
@@ -1198,7 +1198,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
dsCacheCtx.gate().enter();
- try (IgniteInternalTx tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
// Check correctness type of removable object.
GridCacheCountDownLatchValue val =
cast(dsView.get(key), GridCacheCountDownLatchValue.class);
@@ -1254,7 +1254,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
dsCacheCtx.gate().enter();
- try (IgniteInternalTx tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheSemaphoreState val = cast(dsView.get(key), GridCacheSemaphoreState.class);
// Check that semaphore hasn't been created in other thread yet.
@@ -1319,7 +1319,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
dsCacheCtx.gate().enter();
- try (IgniteInternalTx tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
// Check correctness type of removable object.
GridCacheSemaphoreState val = cast(dsView.get(key), GridCacheSemaphoreState.class);
@@ -1371,7 +1371,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
dsCacheCtx.gate().enter();
- try (IgniteInternalTx tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheLockState val = cast(dsView.get(key), GridCacheLockState.class);
// Check that reentrant lock hasn't been created in other thread yet.
@@ -1438,7 +1438,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
dsCacheCtx.gate().enter();
- try (IgniteInternalTx tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
// Check correctness type of removable object.
GridCacheLockState val = cast(dsView.get(key), GridCacheLockState.class);
@@ -1474,7 +1474,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
return CU.outTx(
new Callable<Boolean>() {
@Override public Boolean call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(dsCacheCtx, dsView, PESSIMISTIC, REPEATABLE_READ)) {
// Check correctness type of removable object.
R val = cast(dsView.get(key), cls);
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicLongImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicLongImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicLongImpl.java
index dfd2122..640b72d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicLongImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicLongImpl.java
@@ -29,7 +29,7 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -90,7 +90,7 @@ public final class GridCacheAtomicLongImpl implements GridCacheAtomicLongEx, Ext
/** Callable for {@link #incrementAndGet()}. */
private final Callable<Long> incAndGetCall = retryTopologySafe(new Callable<Long>() {
@Override public Long call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicLongValue val = atomicView.get(key);
if (val == null)
@@ -117,7 +117,7 @@ public final class GridCacheAtomicLongImpl implements GridCacheAtomicLongEx, Ext
/** Callable for {@link #getAndIncrement()}. */
private final Callable<Long> getAndIncCall = retryTopologySafe(new Callable<Long>() {
@Override public Long call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicLongValue val = atomicView.get(key);
if (val == null)
@@ -144,7 +144,7 @@ public final class GridCacheAtomicLongImpl implements GridCacheAtomicLongEx, Ext
/** Callable for {@link #decrementAndGet()}. */
private final Callable<Long> decAndGetCall = retryTopologySafe(new Callable<Long>() {
@Override public Long call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicLongValue val = atomicView.get(key);
if (val == null)
@@ -171,7 +171,7 @@ public final class GridCacheAtomicLongImpl implements GridCacheAtomicLongEx, Ext
/** Callable for {@link #getAndDecrement()}. */
private final Callable<Long> getAndDecCall = retryTopologySafe(new Callable<Long>() {
@Override public Long call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicLongValue val = atomicView.get(key);
if (val == null)
@@ -430,7 +430,7 @@ public final class GridCacheAtomicLongImpl implements GridCacheAtomicLongEx, Ext
private Callable<Long> internalAddAndGet(final long l) {
return retryTopologySafe(new Callable<Long>() {
@Override public Long call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicLongValue val = atomicView.get(key);
if (val == null)
@@ -464,7 +464,7 @@ public final class GridCacheAtomicLongImpl implements GridCacheAtomicLongEx, Ext
private Callable<Long> internalGetAndAdd(final long l) {
return retryTopologySafe(new Callable<Long>() {
@Override public Long call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicLongValue val = atomicView.get(key);
if (val == null)
@@ -498,7 +498,7 @@ public final class GridCacheAtomicLongImpl implements GridCacheAtomicLongEx, Ext
private Callable<Long> internalGetAndSet(final long l) {
return new Callable<Long>() {
@Override public Long call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicLongValue val = atomicView.get(key);
if (val == null)
@@ -534,7 +534,7 @@ public final class GridCacheAtomicLongImpl implements GridCacheAtomicLongEx, Ext
private Callable<Long> internalCompareAndSetAndGet(final long expVal, final long newVal) {
return new Callable<Long>() {
@Override public Long call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicLongValue val = atomicView.get(key);
if (val == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
index 448dd8b..6911b3f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
@@ -29,7 +29,7 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -213,7 +213,7 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
private Callable<Boolean> internalSet(final T val) {
return retryTopologySafe(new Callable<Boolean>() {
@Override public Boolean call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicReferenceValue<T> ref = atomicView.get(key);
if (ref == null)
@@ -247,7 +247,7 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
private Callable<T> internalCompareAndSetAndGet(final T expVal, final T newVal) {
return retryTopologySafe(new Callable<T>() {
@Override public T call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicReferenceValue<T> ref = atomicView.get(key);
if (ref == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
index 754d8f5..87aae8b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
@@ -35,7 +35,7 @@ import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.A;
@@ -486,7 +486,7 @@ public final class GridCacheAtomicSequenceImpl implements GridCacheAtomicSequenc
private Callable<Long> internalUpdate(final long l, final boolean updated) {
return retryTopologySafe(new Callable<Long>() {
@Override public Long call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, seqView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, seqView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicSequenceValue seq = seqView.get(key);
checkRemoved();
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
index 6ac303c..14f80e2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
@@ -29,7 +29,7 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.F0;
import org.apache.ignite.internal.util.tostring.GridToStringBuilder;
import org.apache.ignite.internal.util.typedef.internal.CU;
@@ -267,7 +267,7 @@ public final class GridCacheAtomicStampedImpl<T, S> implements GridCacheAtomicSt
private Callable<Boolean> internalSet(final T val, final S stamp) {
return retryTopologySafe(new Callable<Boolean>() {
@Override public Boolean call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicStampedValue<T, S> stmp = atomicView.get(key);
if (stmp == null)
@@ -305,7 +305,7 @@ public final class GridCacheAtomicStampedImpl<T, S> implements GridCacheAtomicSt
final IgniteClosure<S, S> newStampClos) {
return retryTopologySafe(new Callable<Boolean>() {
@Override public Boolean call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicStampedValue<T, S> stmp = atomicView.get(key);
if (stmp == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
index 723fb55..45c3677 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
@@ -32,7 +32,7 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -282,7 +282,7 @@ public final class GridCacheCountDownLatchImpl implements GridCacheCountDownLatc
internalLatch = CU.outTx(
retryTopologySafe(new Callable<CountDownLatch>() {
@Override public CountDownLatch call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, latchView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, latchView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheCountDownLatchValue val = latchView.get(key);
if (val == null) {
@@ -407,7 +407,7 @@ public final class GridCacheCountDownLatchImpl implements GridCacheCountDownLatc
/** {@inheritDoc} */
@Override public Integer call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, latchView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, latchView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheCountDownLatchValue latchVal = latchView.get(key);
if (latchVal == null) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
index 1cf78fa..5f0cb44 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
@@ -49,7 +49,7 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -520,8 +520,7 @@ public final class GridCacheLockImpl implements GridCacheLockEx, Externalizable
return CU.outTx(
retryTopologySafe(new Callable<Boolean>() {
@Override public Boolean call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, lockView, PESSIMISTIC, REPEATABLE_READ)) {
-
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, lockView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheLockState val = lockView.get(key);
if (val == null)
@@ -614,7 +613,7 @@ public final class GridCacheLockImpl implements GridCacheLockEx, Externalizable
return CU.outTx(
retryTopologySafe(new Callable<Boolean>() {
@Override public Boolean call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, lockView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, lockView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheLockState val = lockView.get(key);
if (val == null)
@@ -711,7 +710,7 @@ public final class GridCacheLockImpl implements GridCacheLockEx, Externalizable
return CU.outTx(
retryTopologySafe(new Callable<Boolean>() {
@Override public Boolean call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, lockView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, lockView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheLockState val = lockView.get(key);
if (val == null)
@@ -1089,7 +1088,7 @@ public final class GridCacheLockImpl implements GridCacheLockEx, Externalizable
sync = CU.outTx(
retryTopologySafe(new Callable<Sync>() {
@Override public Sync call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx, lockView, PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx, lockView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheLockState val = lockView.get(key);
if (val == null) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
index a11c79d..a1c0515 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
@@ -40,7 +40,7 @@ import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -285,7 +285,7 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
return CU.outTx(
retryTopologySafe(new Callable<Boolean>() {
@Override public Boolean call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx,
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx,
semView,
PESSIMISTIC, REPEATABLE_READ)
) {
@@ -359,7 +359,7 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
retryTopologySafe(new Callable<Boolean>() {
@Override public Boolean call() throws Exception {
try (
- IgniteInternalTx tx = CU.txStartInternal(ctx,
+ GridNearTxLocal tx = CU.txStartInternal(ctx,
semView,
PESSIMISTIC, REPEATABLE_READ)
) {
@@ -454,7 +454,7 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
sync = CU.outTx(
retryTopologySafe(new Callable<Sync>() {
@Override public Sync call() throws Exception {
- try (IgniteInternalTx tx = CU.txStartInternal(ctx,
+ try (GridNearTxLocal tx = CU.txStartInternal(ctx,
semView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheSemaphoreState val = semView.get(key);
@@ -465,7 +465,7 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
return null;
}
- final int count = val.getCount();
+ final int cnt = val.getCount();
Map<UUID, Integer> waiters = val.getWaiters();
@@ -473,7 +473,7 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
tx.commit();
- return new Sync(count, waiters, failoverSafe);
+ return new Sync(cnt, waiters, failoverSafe);
}
}
}),
@@ -676,7 +676,7 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
retryTopologySafe(new Callable<Integer>() {
@Override public Integer call() throws Exception {
try (
- IgniteInternalTx tx = CU.txStartInternal(ctx,
+ GridNearTxLocal tx = CU.txStartInternal(ctx,
semView, PESSIMISTIC, REPEATABLE_READ)
) {
GridCacheSemaphoreState val = semView.get(key);
@@ -684,11 +684,11 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
if (val == null)
throw new IgniteException("Failed to find semaphore with given name: " + name);
- int count = val.getCount();
+ int cnt = val.getCount();
tx.rollback();
- return count;
+ return cnt;
}
}
}),
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridTransactionalCacheQueueImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridTransactionalCacheQueueImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridTransactionalCacheQueueImpl.java
index 7b80765..846eb69 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridTransactionalCacheQueueImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridTransactionalCacheQueueImpl.java
@@ -25,7 +25,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteQueue;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;
@@ -57,7 +57,7 @@ public class GridTransactionalCacheQueueImpl<T> extends GridCacheQueueAdapter<T>
@Override public Boolean call() throws Exception {
boolean retVal;
- try (IgniteInternalTx tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
Long idx = (Long)cache.invoke(queueKey, new AddProcessor(id, 1)).get();
if (idx != null) {
@@ -97,7 +97,7 @@ public class GridTransactionalCacheQueueImpl<T> extends GridCacheQueueAdapter<T>
T retVal;
while (true) {
- try (IgniteInternalTx tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
Long idx = (Long)cache.invoke(queueKey, new PollProcessor(id)).get();
if (idx != null) {
@@ -143,7 +143,7 @@ public class GridTransactionalCacheQueueImpl<T> extends GridCacheQueueAdapter<T>
@Override public Boolean call() throws Exception {
boolean retVal;
- try (IgniteInternalTx tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
Long idx = (Long)cache.invoke(queueKey, new AddProcessor(id, items.size())).get();
if (idx != null) {
@@ -188,7 +188,7 @@ public class GridTransactionalCacheQueueImpl<T> extends GridCacheQueueAdapter<T>
try {
retryTopologySafe(new Callable<Object>() {
@Override public Object call() throws Exception {
- try (IgniteInternalTx tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
Long idx = (Long)cache.invoke(queueKey, new RemoveProcessor(id, rmvIdx)).get();
if (idx != null) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index 74fc175..acd0a1f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@ -17,7 +17,31 @@
package org.apache.ignite.internal.processors.igfs;
+import java.io.DataInput;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.MutableEntry;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteException;
@@ -41,7 +65,7 @@ import org.apache.ignite.internal.managers.communication.GridIoPolicy;
import org.apache.ignite.internal.managers.communication.GridMessageListener;
import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerCacheUpdaters;
import org.apache.ignite.internal.processors.igfs.data.IgfsDataPutProcessor;
import org.apache.ignite.internal.processors.task.GridInternal;
@@ -58,31 +82,6 @@ import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.MutableEntry;
-import java.io.DataInput;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Deque;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.internal.GridTopic.TOPIC_IGFS;
@@ -654,7 +653,7 @@ public class IgfsDataManager extends IgfsManager {
// Need to check if block is partially written.
// If so, must update it in pessimistic transaction.
if (block.length != fileInfo.blockSize()) {
- try (IgniteInternalTx tx = dataCachePrj.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = dataCachePrj.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
Map<IgfsBlockKey, byte[]> vals = dataCachePrj.getAll(F.asList(colocatedKey, key));
byte[] val = vals.get(colocatedKey);
@@ -1062,7 +1061,7 @@ public class IgfsDataManager extends IgfsManager {
IgfsBlockKey key = new IgfsBlockKey(colocatedKey.getFileId(), null,
colocatedKey.evictExclude(), colocatedKey.blockId());
- try (IgniteInternalTx tx = dataCachePrj.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = dataCachePrj.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
// Lock keys.
Map<IgfsBlockKey, byte[]> vals = dataCachePrj.getAll(F.asList(colocatedKey, key));
[10/16] ignite git commit: Internal cache API cleanup.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 b1a4003..dc4e52f 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
@@ -18,33 +18,24 @@
package org.apache.ignite.internal.processors.cache.transactions;
import java.io.Externalizable;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import javax.cache.Cache;
-import javax.cache.CacheException;
import javax.cache.expiry.Duration;
import javax.cache.expiry.ExpiryPolicy;
import javax.cache.processor.EntryProcessor;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.NodeStoppingException;
-import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CacheInvokeEntry;
import org.apache.ignite.internal.processors.cache.CacheObject;
-import org.apache.ignite.internal.processors.cache.CacheOperationContext;
-import org.apache.ignite.internal.processors.cache.EntryGetResult;
import org.apache.ignite.internal.processors.cache.EntryProcessorResourceInjectorProxy;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -58,9 +49,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.GridCacheUpdateTxResult;
import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtDetachedCacheEntry;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry;
-import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
import org.apache.ignite.internal.processors.cache.store.CacheStoreManager;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionConflictContext;
@@ -68,36 +56,26 @@ import org.apache.ignite.internal.processors.dr.GridDrType;
import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException;
-import org.apache.ignite.internal.util.GridLeanMap;
-import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
-import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.GridClosureException;
-import org.apache.ignite.internal.util.lang.GridInClosure3;
import org.apache.ignite.internal.util.lang.GridTuple;
import org.apache.ignite.internal.util.tostring.GridToStringBuilder;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.C1;
-import org.apache.ignite.internal.util.typedef.C2;
-import org.apache.ignite.internal.util.typedef.CI2;
import org.apache.ignite.internal.util.typedef.CX1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiClosure;
import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgniteClosure;
-import org.apache.ignite.plugin.security.SecurityPermission;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionDeadlockException;
import org.apache.ignite.transactions.TransactionIsolation;
import org.apache.ignite.transactions.TransactionState;
import org.jetbrains.annotations.Nullable;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ;
import static org.apache.ignite.internal.processors.cache.GridCacheOperation.CREATE;
import static org.apache.ignite.internal.processors.cache.GridCacheOperation.DELETE;
import static org.apache.ignite.internal.processors.cache.GridCacheOperation.NOOP;
@@ -105,8 +83,6 @@ import static org.apache.ignite.internal.processors.cache.GridCacheOperation.REA
import static org.apache.ignite.internal.processors.cache.GridCacheOperation.RELOAD;
import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRANSFORM;
import static org.apache.ignite.internal.processors.cache.GridCacheOperation.UPDATE;
-import static org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry.SER_READ_EMPTY_ENTRY_VER;
-import static org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry.SER_READ_NOT_EMPTY_VER;
import static org.apache.ignite.internal.processors.dr.GridDrType.DR_NONE;
import static org.apache.ignite.internal.processors.dr.GridDrType.DR_PRIMARY;
import static org.apache.ignite.transactions.TransactionState.COMMITTED;
@@ -164,6 +140,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
@GridToStringInclude
protected IgniteTxLocalState txState;
+ /** */
+ protected CacheWriteSynchronizationMode syncMode;
+
/**
* Empty constructor required for {@link Externalizable}.
*/
@@ -224,6 +203,23 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
txState = implicitSingle ? new IgniteTxImplicitSingleStateImpl() : new IgniteTxStateImpl();
}
+ /**
+ * @return Transaction write synchronization mode.
+ */
+ public final CacheWriteSynchronizationMode syncMode() {
+ if (syncMode != null)
+ return syncMode;
+
+ return txState().syncMode(cctx);
+ }
+
+ /**
+ * @param syncMode Write synchronization mode.
+ */
+ public void syncMode(CacheWriteSynchronizationMode syncMode) {
+ this.syncMode = syncMode;
+ }
+
/** {@inheritDoc} */
@Override public IgniteTxState txState() {
return txState;
@@ -391,142 +387,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
return null;
}
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Void> loadMissing(
- final GridCacheContext cacheCtx,
- final AffinityTopologyVersion topVer,
- final boolean readThrough,
- boolean async,
- final Collection<KeyCacheObject> keys,
- boolean skipVals,
- boolean needVer,
- boolean keepBinary,
- final ExpiryPolicy expiryPlc,
- final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c
- ) {
- assert cacheCtx.isLocal() : cacheCtx.name();
-
- if (!readThrough || !cacheCtx.readThrough()) {
- for (KeyCacheObject key : keys)
- c.apply(key, null, SER_READ_EMPTY_ENTRY_VER);
-
- return new GridFinishedFuture<>();
- }
-
- try {
- IgniteCacheExpiryPolicy expiryPlc0 = optimistic() ?
- accessPolicy(cacheCtx, keys) :
- cacheCtx.cache().expiryPolicy(expiryPlc);
-
- Map<KeyCacheObject, GridCacheVersion> misses = null;
-
- for (KeyCacheObject key : keys) {
- while (true) {
- IgniteTxEntry txEntry = entry(cacheCtx.txKey(key));
-
- GridCacheEntryEx entry = txEntry == null ? cacheCtx.cache().entryEx(key) :
- txEntry.cached();
-
- if (entry == null)
- continue;
-
- try {
- EntryGetResult res = entry.innerGetVersioned(
- null,
- this,
- /*readSwap*/true,
- /*unmarshal*/true,
- /*update-metrics*/!skipVals,
- /*event*/!skipVals,
- CU.subjectId(this, cctx),
- null,
- resolveTaskName(),
- expiryPlc0,
- txEntry == null ? keepBinary : txEntry.keepBinary(),
- null);
-
- if (res == null) {
- if (misses == null)
- misses = new LinkedHashMap<>();
-
- misses.put(key, entry.version());
- }
- else
- c.apply(key, skipVals ? true : res.value(), res.version());
-
- break;
- }
- catch (GridCacheEntryRemovedException ignore) {
- if (log.isDebugEnabled())
- log.debug("Got removed entry, will retry: " + key);
-
- if (txEntry != null)
- txEntry.cached(cacheCtx.cache().entryEx(key, topologyVersion()));
- }
- }
- }
-
- if (misses != null) {
- final Map<KeyCacheObject, GridCacheVersion> misses0 = misses;
-
- cacheCtx.store().loadAll(this, misses.keySet(), new CI2<KeyCacheObject, Object>() {
- @Override public void apply(KeyCacheObject key, Object val) {
- GridCacheVersion ver = misses0.remove(key);
-
- assert ver != null : key;
-
- if (val != null) {
- CacheObject cacheVal = cacheCtx.toCacheObject(val);
-
- while (true) {
- GridCacheEntryEx entry = cacheCtx.cache().entryEx(key, topVer);
-
- try {
- EntryGetResult verVal = entry.versionedValue(cacheVal,
- ver,
- null,
- null,
- null);
-
- if (log.isDebugEnabled()) {
- log.debug("Set value loaded from store into entry [" +
- "oldVer=" + ver +
- ", newVer=" + verVal.version() +
- ", entry=" + entry + ']');
- }
-
- ver = verVal.version();
-
- break;
- }
- catch (GridCacheEntryRemovedException ignore) {
- if (log.isDebugEnabled())
- log.debug("Got removed entry, (will retry): " + entry);
- }
- catch (IgniteCheckedException e) {
- // Wrap errors (will be unwrapped).
- throw new GridClosureException(e);
- }
- }
- }
- else
- ver = SER_READ_EMPTY_ENTRY_VER;
-
- c.apply(key, val, ver);
- }
- });
-
- for (KeyCacheObject key : misses0.keySet())
- c.apply(key, null, SER_READ_EMPTY_ENTRY_VER);
- }
-
- return new GridFinishedFuture<>();
- }
- catch (IgniteCheckedException e) {
- return new GridFinishedFuture<>(e);
- }
- }
-
/**
* Gets minimum version present in transaction.
*
@@ -571,21 +431,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
}
}
- /** {@inheritDoc} */
- @Override public void commit() throws IgniteCheckedException {
- try {
- commitAsync().get();
- }
- finally {
- cctx.tm().resetContext();
- }
- }
-
- /** {@inheritDoc} */
- @Override public void prepare() throws IgniteCheckedException {
- prepareAsync().get();
- }
-
/**
* Checks that locks are in proper state for commit.
*
@@ -1103,2484 +948,226 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
}
/**
- * @param entry Entry.
- * @return {@code True} if local node is current primary for given entry.
+ * @param ctx Cache context.
+ * @param key Key.
+ * @param expiryPlc Expiry policy.
+ * @return Expiry policy wrapper for entries accessed locally in optimistic transaction.
*/
- private boolean primaryLocal(GridCacheEntryEx entry) {
- return entry.context().affinity().primaryByPartition(cctx.localNode(), entry.partition(), AffinityTopologyVersion.NONE);
+ protected IgniteCacheExpiryPolicy accessPolicy(
+ GridCacheContext ctx,
+ IgniteTxKey key,
+ @Nullable ExpiryPolicy expiryPlc
+ ) {
+ return null;
}
/**
* @param cacheCtx Cache context.
- * @param keys Key to enlist.
- * @param expiryPlc Explicitly specified expiry policy for entry.
- * @param map Return map.
- * @param missed Map of missed keys.
- * @param keysCnt Keys count (to avoid call to {@code Collection.size()}).
- * @param deserializeBinary Deserialize binary flag.
- * @param skipVals Skip values flag.
- * @param keepCacheObjects Keep cache objects flag.
- * @param skipStore Skip store flag.
- * @throws IgniteCheckedException If failed.
- * @return Enlisted keys.
+ * @param keys Keys.
+ * @return Expiry policy.
*/
- @SuppressWarnings({"RedundantTypeArguments"})
- private <K, V> Collection<KeyCacheObject> enlistRead(
- final GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- Collection<KeyCacheObject> keys,
- @Nullable ExpiryPolicy expiryPlc,
- Map<K, V> map,
- Map<KeyCacheObject, GridCacheVersion> missed,
- int keysCnt,
- boolean deserializeBinary,
- boolean skipVals,
- boolean keepCacheObjects,
- boolean skipStore,
- final boolean needVer
- ) throws IgniteCheckedException {
- assert !F.isEmpty(keys);
- assert keysCnt == keys.size();
-
- cacheCtx.checkSecurity(SecurityPermission.CACHE_READ);
-
- boolean single = keysCnt == 1;
-
- Collection<KeyCacheObject> lockKeys = null;
-
- AffinityTopologyVersion topVer = entryTopVer != null ? entryTopVer : topologyVersion();
-
- boolean needReadVer = (serializable() && optimistic()) || needVer;
-
- // In this loop we cover only read-committed or optimistic transactions.
- // Transactions that are pessimistic and not read-committed are covered
- // outside of this loop.
- for (KeyCacheObject key : keys) {
- if ((pessimistic() || needReadVer) && !readCommitted() && !skipVals)
- addActiveCache(cacheCtx);
-
- IgniteTxKey txKey = cacheCtx.txKey(key);
-
- // Check write map (always check writes first).
- IgniteTxEntry txEntry = entry(txKey);
-
- // Either non-read-committed or there was a previous write.
- if (txEntry != null) {
- CacheObject val = txEntry.value();
-
- if (txEntry.hasValue()) {
- if (!F.isEmpty(txEntry.entryProcessors()))
- val = txEntry.applyEntryProcessors(val);
-
- if (val != null) {
- GridCacheVersion ver = null;
-
- if (needVer) {
- if (txEntry.op() != READ)
- ver = IgniteTxEntry.GET_ENTRY_INVALID_VER_UPDATED;
- else {
- ver = txEntry.entryReadVersion();
+ protected IgniteCacheExpiryPolicy accessPolicy(GridCacheContext cacheCtx, Collection<KeyCacheObject> keys) {
+ return null;
+ }
- if (ver == null && pessimistic()) {
- while (true) {
- try {
- GridCacheEntryEx cached = txEntry.cached();
+ /**
+ * Post lock processing for put or remove.
+ *
+ * @param cacheCtx Context.
+ * @param keys Keys.
+ * @param ret Return value.
+ * @param rmv {@code True} if remove.
+ * @param retval Flag to return value or not.
+ * @param read {@code True} if read.
+ * @param accessTtl TTL for read operation.
+ * @param filter Filter to check entries.
+ * @throws IgniteCheckedException If error.
+ * @param computeInvoke If {@code true} computes return value for invoke operation.
+ */
+ @SuppressWarnings("unchecked")
+ protected final void postLockWrite(
+ GridCacheContext cacheCtx,
+ Iterable<KeyCacheObject> keys,
+ GridCacheReturn ret,
+ boolean rmv,
+ boolean retval,
+ boolean read,
+ long accessTtl,
+ CacheEntryPredicate[] filter,
+ boolean computeInvoke
+ ) throws IgniteCheckedException {
+ for (KeyCacheObject k : keys) {
+ IgniteTxEntry txEntry = entry(cacheCtx.txKey(k));
- ver = cached.isNear() ?
- ((GridNearCacheEntry)cached).dhtVersion() : cached.version();
+ if (txEntry == null)
+ throw new IgniteCheckedException("Transaction entry is null (most likely collection of keys passed into cache " +
+ "operation was changed before operation completed) [missingKey=" + k + ", tx=" + this + ']');
- break;
- }
- catch (GridCacheEntryRemovedException ignored) {
- txEntry.cached(entryEx(cacheCtx, txEntry.txKey(), topVer));
- }
- }
- }
+ while (true) {
+ GridCacheEntryEx cached = txEntry.cached();
- if (ver == null) {
- assert optimistic() && repeatableRead() : this;
+ try {
+ assert cached.detached() || cached.lockedByThread(threadId) || isRollbackOnly() :
+ "Transaction lock is not acquired [entry=" + cached + ", tx=" + this +
+ ", nodeId=" + cctx.localNodeId() + ", threadId=" + threadId + ']';
- ver = IgniteTxEntry.GET_ENTRY_INVALID_VER_AFTER_GET;
- }
- }
+ if (log.isDebugEnabled())
+ log.debug("Post lock write entry: " + cached);
- assert ver != null;
- }
+ CacheObject v = txEntry.previousValue();
+ boolean hasPrevVal = txEntry.hasPreviousValue();
- cacheCtx.addResult(map, key, val, skipVals, keepCacheObjects, deserializeBinary, false,
- ver, 0, 0);
- }
- }
- else {
- assert txEntry.op() == TRANSFORM;
+ if (onePhaseCommit())
+ filter = txEntry.filters();
- while (true) {
- try {
- GridCacheVersion readVer = null;
- EntryGetResult getRes = null;
+ // If we have user-passed filter, we must read value into entry for peek().
+ if (!F.isEmptyOrNulls(filter) && !F.isAlwaysTrue(filter))
+ retval = true;
- Object transformClo =
- (txEntry.op() == TRANSFORM &&
- cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ)) ?
- F.first(txEntry.entryProcessors()) : null;
+ boolean invoke = txEntry.op() == TRANSFORM;
- if (needVer) {
- getRes = txEntry.cached().innerGetVersioned(
- null,
- this,
- /*swap*/true,
- /*unmarshal*/true,
- /*update-metrics*/true,
- /*event*/!skipVals,
- CU.subjectId(this, cctx),
- transformClo,
- resolveTaskName(),
- null,
- txEntry.keepBinary(),
- null);
+ if (retval || invoke) {
+ if (!cacheCtx.isNear()) {
+ if (!hasPrevVal) {
+ // For non-local cache should read from store after lock on primary.
+ boolean readThrough = cacheCtx.isLocal() &&
+ (invoke || cacheCtx.loadPreviousValue()) &&
+ !txEntry.skipStore();
- if (getRes != null) {
- val = getRes.value();
- readVer = getRes.version();
- }
- }
- else {
- val = txEntry.cached().innerGet(
+ v = cached.innerGet(
null,
this,
/*swap*/true,
- /*read-through*/false,
- /*metrics*/true,
- /*event*/!skipVals,
+ readThrough,
+ /*metrics*/!invoke,
+ /*event*/!invoke && !dht(),
/*temporary*/false,
CU.subjectId(this, cctx),
- transformClo,
+ null,
resolveTaskName(),
null,
txEntry.keepBinary());
}
-
- if (val != null) {
- if (!readCommitted() && !skipVals)
- txEntry.readValue(val);
-
- if (!F.isEmpty(txEntry.entryProcessors()))
- val = txEntry.applyEntryProcessors(val);
-
- cacheCtx.addResult(map,
- key,
- val,
- skipVals,
- keepCacheObjects,
- deserializeBinary,
- false,
- getRes,
- readVer,
- 0,
- 0,
- needVer);
- }
- else
- missed.put(key, txEntry.cached().version());
-
- break;
}
- catch (GridCacheEntryRemovedException ignored) {
- txEntry.cached(entryEx(cacheCtx, txEntry.txKey(), topVer));
+ else {
+ if (!hasPrevVal)
+ v = cached.rawGetOrUnmarshal(false);
}
- }
- }
- }
- // First time access within transaction.
- else {
- if (lockKeys == null && !skipVals)
- lockKeys = single ? Collections.singleton(key) : new ArrayList<KeyCacheObject>(keysCnt);
- if (!single && !skipVals)
- lockKeys.add(key);
+ if (txEntry.op() == TRANSFORM) {
+ if (computeInvoke) {
+ GridCacheVersion ver;
+
+ try {
+ ver = cached.version();
+ }
+ catch (GridCacheEntryRemovedException e) {
+ assert optimistic() : txEntry;
- while (true) {
- GridCacheEntryEx entry = entryEx(cacheCtx, txKey, topVer);
+ if (log.isDebugEnabled())
+ log.debug("Failed to get entry version: [msg=" + e.getMessage() + ']');
- try {
- GridCacheVersion ver = entry.version();
-
- CacheObject val = null;
- GridCacheVersion readVer = null;
- EntryGetResult getRes = null;
-
- if (!pessimistic() || readCommitted() && !skipVals) {
- IgniteCacheExpiryPolicy accessPlc =
- optimistic() ? accessPolicy(cacheCtx, txKey, expiryPlc) : null;
-
- if (needReadVer) {
- getRes = primaryLocal(entry) ?
- entry.innerGetVersioned(
- null,
- this,
- /*swap*/true,
- /*unmarshal*/true,
- /*metrics*/true,
- /*event*/true,
- CU.subjectId(this, cctx),
- null,
- resolveTaskName(),
- accessPlc,
- !deserializeBinary,
- null) : null;
-
- if (getRes != null) {
- val = getRes.value();
- readVer = getRes.version();
+ ver = null;
}
- }
- else {
- val = entry.innerGet(
- null,
- this,
- /*swap*/true,
- /*read-through*/false,
- /*metrics*/true,
- /*event*/true,
- /*temporary*/false,
- CU.subjectId(this, cctx),
- null,
- resolveTaskName(),
- accessPlc,
- !deserializeBinary);
- }
- if (val != null) {
- cacheCtx.addResult(map,
- key,
- val,
- skipVals,
- keepCacheObjects,
- deserializeBinary,
- false,
- getRes,
- readVer,
- 0,
- 0,
- needVer);
+ addInvokeResult(txEntry, v, ret, ver);
}
- else
- missed.put(key, ver);
}
else
- // We must wait for the lock in pessimistic mode.
- missed.put(key, ver);
-
- if (!readCommitted() && !skipVals) {
- txEntry = addEntry(READ,
- val,
- null,
- null,
- entry,
- expiryPlc,
- null,
- true,
- -1L,
- -1L,
- null,
- skipStore,
- !deserializeBinary);
-
- // As optimization, mark as checked immediately
- // for non-pessimistic if value is not null.
- if (val != null && !pessimistic()) {
- txEntry.markValid();
-
- if (needReadVer) {
- assert readVer != null;
-
- txEntry.entryReadVersion(readVer);
- }
- }
- }
-
- break; // While.
+ ret.value(cacheCtx, v, txEntry.keepBinary());
}
- catch (GridCacheEntryRemovedException ignored) {
+
+ boolean pass = F.isEmpty(filter) || cacheCtx.isAll(cached, filter);
+
+ // For remove operation we return true only if we are removing s/t,
+ // i.e. cached value is not null.
+ ret.success(pass && (!retval ? !rmv || cached.hasValue() || v != null : !rmv || v != null));
+
+ if (onePhaseCommit())
+ txEntry.filtersPassed(pass);
+
+ boolean updateTtl = read;
+
+ if (pass) {
+ txEntry.markValid();
+
if (log.isDebugEnabled())
- log.debug("Got removed entry in transaction getAllAsync(..) (will retry): " + key);
+ log.debug("Filter passed in post lock for key: " + k);
}
- finally {
- if (entry != null && readCommitted()) {
- if (cacheCtx.isNear()) {
- if (cacheCtx.affinity().partitionBelongs(cacheCtx.localNode(), entry.partition(), topVer)) {
- if (entry.markObsolete(xidVer))
- cacheCtx.cache().removeEntry(entry);
- }
- }
- else
- entry.context().evicts().touch(entry, topVer);
- }
+ else {
+ // Revert operation to previous. (if no - NOOP, so entry will be unlocked).
+ txEntry.setAndMarkValid(txEntry.previousOperation(), cacheCtx.toCacheObject(ret.value()));
+ txEntry.filters(CU.empty0());
+ txEntry.filtersSet(false);
+
+ updateTtl = !cacheCtx.putIfAbsentFilter(filter);
}
- }
- }
- }
- return lockKeys != null ? lockKeys : Collections.<KeyCacheObject>emptyList();
- }
+ if (updateTtl) {
+ if (!read) {
+ ExpiryPolicy expiryPlc = cacheCtx.expiryForTxEntry(txEntry);
- /**
- * @param ctx Cache context.
- * @param key Key.
- * @param expiryPlc Expiry policy.
- * @return Expiry policy wrapper for entries accessed locally in optimistic transaction.
- */
- protected IgniteCacheExpiryPolicy accessPolicy(
- GridCacheContext ctx,
- IgniteTxKey key,
- @Nullable ExpiryPolicy expiryPlc
- ) {
- return null;
- }
-
- /**
- * @param cacheCtx Cache context.
- * @param keys Keys.
- * @return Expiry policy.
- */
- protected IgniteCacheExpiryPolicy accessPolicy(GridCacheContext cacheCtx, Collection<KeyCacheObject> keys) {
- return null;
- }
-
- /**
- * @param cacheCtx Cache context.
- * @param topVer Topology version.
- * @param map Return map.
- * @param missedMap Missed keys.
- * @param deserializeBinary Deserialize binary flag.
- * @param skipVals Skip values flag.
- * @param keepCacheObjects Keep cache objects flag.
- * @param skipStore Skip store flag.
- * @param expiryPlc Expiry policy.
- * @return Loaded key-value pairs.
- */
- private <K, V> IgniteInternalFuture<Map<K, V>> checkMissed(
- final GridCacheContext cacheCtx,
- final AffinityTopologyVersion topVer,
- final Map<K, V> map,
- final Map<KeyCacheObject, GridCacheVersion> missedMap,
- final boolean deserializeBinary,
- final boolean skipVals,
- final boolean keepCacheObjects,
- final boolean skipStore,
- final boolean needVer,
- final ExpiryPolicy expiryPlc
-
- ) {
- if (log.isDebugEnabled())
- log.debug("Loading missed values for missed map: " + missedMap);
-
- final boolean needReadVer = (serializable() && optimistic()) || needVer;
-
- return new GridEmbeddedFuture<>(
- new C2<Void, Exception, Map<K, V>>() {
- @Override public Map<K, V> apply(Void v, Exception e) {
- if (e != null) {
- setRollbackOnly();
-
- throw new GridClosureException(e);
- }
-
- return map;
- }
- },
- loadMissing(
- cacheCtx,
- topVer,
- !skipStore,
- false,
- missedMap.keySet(),
- skipVals,
- needReadVer,
- !deserializeBinary,
- expiryPlc,
- new GridInClosure3<KeyCacheObject, Object, GridCacheVersion>() {
- @Override public void apply(KeyCacheObject key, Object val, GridCacheVersion loadVer) {
- if (isRollbackOnly()) {
- if (log.isDebugEnabled())
- log.debug("Ignoring loaded value for read because transaction was rolled back: " +
- IgniteTxLocalAdapter.this);
-
- return;
- }
-
- CacheObject cacheVal = cacheCtx.toCacheObject(val);
-
- CacheObject visibleVal = cacheVal;
-
- IgniteTxKey txKey = cacheCtx.txKey(key);
-
- IgniteTxEntry txEntry = entry(txKey);
-
- if (txEntry != null) {
- if (!readCommitted())
- txEntry.readValue(cacheVal);
-
- if (!F.isEmpty(txEntry.entryProcessors()))
- visibleVal = txEntry.applyEntryProcessors(visibleVal);
- }
-
- assert txEntry != null || readCommitted() || skipVals;
-
- GridCacheEntryEx e = txEntry == null ? entryEx(cacheCtx, txKey, topVer) : txEntry.cached();
-
- if (readCommitted() || skipVals) {
- cacheCtx.evicts().touch(e, topologyVersion());
-
- if (visibleVal != null) {
- cacheCtx.addResult(map,
- key,
- visibleVal,
- skipVals,
- keepCacheObjects,
- deserializeBinary,
- false,
- needVer ? loadVer : null,
- 0,
- 0);
- }
- }
- else {
- assert txEntry != null;
-
- txEntry.setAndMarkValid(cacheVal);
-
- if (needReadVer) {
- assert loadVer != null;
-
- txEntry.entryReadVersion(loadVer);
- }
-
- if (visibleVal != null) {
- cacheCtx.addResult(map,
- key,
- visibleVal,
- skipVals,
- keepCacheObjects,
- deserializeBinary,
- false,
- needVer ? loadVer : null,
- 0,
- 0);
- }
- }
- }
- })
- );
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public <K, V> IgniteInternalFuture<Map<K, V>> getAllAsync(
- final GridCacheContext cacheCtx,
- @Nullable final AffinityTopologyVersion entryTopVer,
- Collection<KeyCacheObject> keys,
- final boolean deserializeBinary,
- final boolean skipVals,
- final boolean keepCacheObjects,
- final boolean skipStore,
- final boolean needVer) {
- if (F.isEmpty(keys))
- return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
-
- init();
-
- int keysCnt = keys.size();
-
- boolean single = keysCnt == 1;
-
- try {
- checkValid();
-
- final Map<K, V> retMap = new GridLeanMap<>(keysCnt);
-
- final Map<KeyCacheObject, GridCacheVersion> missed = new GridLeanMap<>(pessimistic() ? keysCnt : 0);
-
- CacheOperationContext opCtx = cacheCtx.operationContextPerCall();
-
- ExpiryPolicy expiryPlc = opCtx != null ? opCtx.expiry() : null;
-
- final Collection<KeyCacheObject> lockKeys = enlistRead(cacheCtx,
- entryTopVer,
- keys,
- expiryPlc,
- retMap,
- missed,
- keysCnt,
- deserializeBinary,
- skipVals,
- keepCacheObjects,
- skipStore,
- needVer);
-
- if (single && missed.isEmpty())
- return new GridFinishedFuture<>(retMap);
-
- // Handle locks.
- if (pessimistic() && !readCommitted() && !skipVals) {
- if (expiryPlc == null)
- expiryPlc = cacheCtx.expiry();
-
- long accessTtl = expiryPlc != null ? CU.toTtl(expiryPlc.getExpiryForAccess()) : CU.TTL_NOT_CHANGED;
- long createTtl = expiryPlc != null ? CU.toTtl(expiryPlc.getExpiryForCreation()) : CU.TTL_NOT_CHANGED;
-
- long timeout = remainingTime();
-
- if (timeout == -1)
- return new GridFinishedFuture<>(timeoutException());
-
- IgniteInternalFuture<Boolean> fut = cacheCtx.cache().txLockAsync(lockKeys,
- timeout,
- this,
- true,
- true,
- isolation,
- isInvalidate(),
- createTtl,
- accessTtl);
-
- final ExpiryPolicy expiryPlc0 = expiryPlc;
-
- PLC2<Map<K, V>> plc2 = new PLC2<Map<K, V>>() {
- @Override public IgniteInternalFuture<Map<K, V>> postLock() throws IgniteCheckedException {
- if (log.isDebugEnabled())
- log.debug("Acquired transaction lock for read on keys: " + lockKeys);
-
- // Load keys only after the locks have been acquired.
- for (KeyCacheObject cacheKey : lockKeys) {
- K keyVal = (K)
- (keepCacheObjects ? cacheKey :
- cacheCtx.cacheObjectContext().unwrapBinaryIfNeeded(cacheKey, !deserializeBinary));
-
- if (retMap.containsKey(keyVal))
- // We already have a return value.
- continue;
-
- IgniteTxKey txKey = cacheCtx.txKey(cacheKey);
-
- IgniteTxEntry txEntry = entry(txKey);
-
- assert txEntry != null;
-
- // Check if there is cached value.
- while (true) {
- GridCacheEntryEx cached = txEntry.cached();
-
- CacheObject val = null;
- GridCacheVersion readVer = null;
- EntryGetResult getRes = null;
-
- try {
- Object transformClo =
- (!F.isEmpty(txEntry.entryProcessors()) &&
- cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ)) ?
- F.first(txEntry.entryProcessors()) : null;
-
- if (needVer) {
- getRes = cached.innerGetVersioned(
- null,
- IgniteTxLocalAdapter.this,
- /*swap*/cacheCtx.isSwapOrOffheapEnabled(),
- /*unmarshal*/true,
- /*update-metrics*/true,
- /*event*/!skipVals,
- CU.subjectId(IgniteTxLocalAdapter.this, cctx),
- transformClo,
- resolveTaskName(),
- null,
- txEntry.keepBinary(),
- null);
-
- if (getRes != null) {
- val = getRes.value();
- readVer = getRes.version();
- }
- }
- else{
- val = cached.innerGet(
- null,
- IgniteTxLocalAdapter.this,
- cacheCtx.isSwapOrOffheapEnabled(),
- /*read-through*/false,
- /*metrics*/true,
- /*events*/!skipVals,
- /*temporary*/false,
- CU.subjectId(IgniteTxLocalAdapter.this, cctx),
- transformClo,
- resolveTaskName(),
- null,
- txEntry.keepBinary());
- }
-
- // If value is in cache and passed the filter.
- if (val != null) {
- missed.remove(cacheKey);
-
- txEntry.setAndMarkValid(val);
-
- if (!F.isEmpty(txEntry.entryProcessors()))
- val = txEntry.applyEntryProcessors(val);
-
- cacheCtx.addResult(retMap,
- cacheKey,
- val,
- skipVals,
- keepCacheObjects,
- deserializeBinary,
- false,
- getRes,
- readVer,
- 0,
- 0,
- needVer);
-
- if (readVer != null)
- txEntry.entryReadVersion(readVer);
- }
-
- // Even though we bring the value back from lock acquisition,
- // we still need to recheck primary node for consistent values
- // in case of concurrent transactional locks.
-
- break; // While.
- }
- catch (GridCacheEntryRemovedException ignore) {
- if (log.isDebugEnabled())
- log.debug("Got removed exception in get postLock (will retry): " +
- cached);
-
- txEntry.cached(entryEx(cacheCtx, txKey, topologyVersion()));
- }
- }
- }
-
- if (!missed.isEmpty() && cacheCtx.isLocal()) {
- AffinityTopologyVersion topVer = topologyVersionSnapshot();
-
- if (topVer == null)
- topVer = entryTopVer;
-
- return checkMissed(cacheCtx,
- topVer != null ? topVer : topologyVersion(),
- retMap,
- missed,
- deserializeBinary,
- skipVals,
- keepCacheObjects,
- skipStore,
- needVer,
- expiryPlc0);
- }
-
- return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
- }
- };
-
- FinishClosure<Map<K, V>> finClos = new FinishClosure<Map<K, V>>() {
- @Override Map<K, V> finish(Map<K, V> loaded) {
- retMap.putAll(loaded);
-
- return retMap;
- }
- };
-
- if (fut.isDone()) {
- try {
- IgniteInternalFuture<Map<K, V>> fut1 = plc2.apply(fut.get(), null);
-
- return fut1.isDone() ?
- new GridFinishedFuture<>(finClos.apply(fut1.get(), null)) :
- new GridEmbeddedFuture<>(finClos, fut1);
- }
- catch (GridClosureException e) {
- return new GridFinishedFuture<>(e.unwrap());
- }
- catch (IgniteCheckedException e) {
- try {
- return plc2.apply(false, e);
- }
- catch (Exception e1) {
- return new GridFinishedFuture<>(e1);
- }
- }
- }
- else {
- return new GridEmbeddedFuture<>(
- fut,
- plc2,
- finClos);
- }
- }
- else {
- assert optimistic() || readCommitted() || skipVals;
-
- if (!missed.isEmpty()) {
- if (!readCommitted())
- for (Iterator<KeyCacheObject> it = missed.keySet().iterator(); it.hasNext(); ) {
- KeyCacheObject cacheKey = it.next();
-
- K keyVal =
- (K)(keepCacheObjects ? cacheKey : cacheKey.value(cacheCtx.cacheObjectContext(), false));
-
- if (retMap.containsKey(keyVal))
- it.remove();
- }
-
- if (missed.isEmpty())
- return new GridFinishedFuture<>(retMap);
-
- AffinityTopologyVersion topVer = topologyVersionSnapshot();
-
- if (topVer == null)
- topVer = entryTopVer;
-
- return checkMissed(cacheCtx,
- topVer != null ? topVer : topologyVersion(),
- retMap,
- missed,
- deserializeBinary,
- skipVals,
- keepCacheObjects,
- skipStore,
- needVer,
- expiryPlc);
- }
-
- return new GridFinishedFuture<>(retMap);
- }
- }
- catch (IgniteCheckedException e) {
- setRollbackOnly();
-
- return new GridFinishedFuture<>(e);
- }
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public <K, V> IgniteInternalFuture<GridCacheReturn> putAllAsync(
- GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- Map<? extends K, ? extends V> map,
- boolean retval
- ) {
- return (IgniteInternalFuture<GridCacheReturn>)putAllAsync0(cacheCtx,
- entryTopVer,
- map,
- null,
- null,
- null,
- retval);
- }
-
- /** {@inheritDoc} */
- @Override public <K, V> IgniteInternalFuture<GridCacheReturn> putAsync(
- GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- K key,
- V val,
- boolean retval,
- CacheEntryPredicate filter) {
- return putAsync0(cacheCtx,
- entryTopVer,
- key,
- val,
- null,
- null,
- retval,
- filter);
- }
-
- /** {@inheritDoc} */
- @Override public <K, V> IgniteInternalFuture<GridCacheReturn> invokeAsync(GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- K key,
- EntryProcessor<K, V, Object> entryProcessor,
- Object... invokeArgs) {
- return (IgniteInternalFuture)putAsync0(cacheCtx,
- entryTopVer,
- key,
- null,
- entryProcessor,
- invokeArgs,
- true,
- null);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> putAllDrAsync(
- GridCacheContext cacheCtx,
- Map<KeyCacheObject, GridCacheDrInfo> drMap
- ) {
- Map<KeyCacheObject, Object> map = F.viewReadOnly(drMap, new IgniteClosure<GridCacheDrInfo, Object>() {
- @Override public Object apply(GridCacheDrInfo val) {
- return val.value();
- }
- });
-
- return this.<Object, Object>putAllAsync0(cacheCtx,
- null,
- map,
- null,
- null,
- drMap,
- false);
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public <K, V, T> IgniteInternalFuture<GridCacheReturn> invokeAsync(
- GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- @Nullable Map<? extends K, ? extends EntryProcessor<K, V, Object>> map,
- Object... invokeArgs
- ) {
- return (IgniteInternalFuture<GridCacheReturn>)putAllAsync0(cacheCtx,
- entryTopVer,
- null,
- map,
- invokeArgs,
- null,
- true);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> removeAllDrAsync(
- GridCacheContext cacheCtx,
- Map<KeyCacheObject, GridCacheVersion> drMap
- ) {
- return removeAllAsync0(cacheCtx, null, null, drMap, false, null, false);
- }
-
- /**
- * Checks filter for non-pessimistic transactions.
- *
- * @param cctx Cache context.
- * @param key Key.
- * @param val Value.
- * @param filter Filter to check.
- * @return {@code True} if passed or pessimistic.
- */
- private boolean filter(
- GridCacheContext cctx,
- KeyCacheObject key,
- CacheObject val,
- CacheEntryPredicate[] filter) {
- return pessimistic() || (optimistic() && implicit()) || isAll(cctx, key, val, filter);
- }
-
- /**
- * @param cacheCtx Cache context.
- * @param cacheKey Key to enlist.
- * @param val Value.
- * @param expiryPlc Explicitly specified expiry policy for entry.
- * @param entryProcessor Entry processor (for invoke operation).
- * @param invokeArgs Optional arguments for EntryProcessor.
- * @param retval Flag indicating whether a value should be returned.
- * @param lockOnly If {@code true}, then entry will be enlisted as noop.
- * @param filter User filters.
- * @param ret Return value.
- * @param skipStore Skip store flag.
- * @param singleRmv {@code True} for single key remove operation ({@link Cache#remove(Object)}.
- * @return Future for entry values loading.
- */
- private <K, V> IgniteInternalFuture<Void> enlistWrite(
- final GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- KeyCacheObject cacheKey,
- Object val,
- @Nullable ExpiryPolicy expiryPlc,
- @Nullable EntryProcessor<K, V, Object> entryProcessor,
- @Nullable Object[] invokeArgs,
- final boolean retval,
- boolean lockOnly,
- final CacheEntryPredicate[] filter,
- final GridCacheReturn ret,
- boolean skipStore,
- final boolean singleRmv,
- boolean keepBinary,
- Byte dataCenterId) {
- try {
- addActiveCache(cacheCtx);
-
- final boolean hasFilters = !F.isEmptyOrNulls(filter) && !F.isAlwaysTrue(filter);
- final boolean needVal = singleRmv || retval || hasFilters;
- final boolean needReadVer = needVal && (serializable() && optimistic());
-
- if (entryProcessor != null)
- transform = true;
-
- GridCacheVersion drVer = dataCenterId != null ? cctx.versions().next(dataCenterId) : null;
-
- boolean loadMissed = enlistWriteEntry(cacheCtx,
- entryTopVer,
- cacheKey,
- val,
- entryProcessor,
- invokeArgs,
- expiryPlc,
- retval,
- lockOnly,
- filter,
- /*drVer*/drVer,
- /*drTtl*/-1L,
- /*drExpireTime*/-1L,
- ret,
- /*enlisted*/null,
- skipStore,
- singleRmv,
- hasFilters,
- needVal,
- needReadVer,
- keepBinary);
-
- if (loadMissed) {
- AffinityTopologyVersion topVer = topologyVersionSnapshot();
-
- if (topVer == null)
- topVer = entryTopVer;
-
- return loadMissing(cacheCtx,
- topVer != null ? topVer : topologyVersion(),
- Collections.singleton(cacheKey),
- filter,
- ret,
- needReadVer,
- singleRmv,
- hasFilters,
- /*read through*/(entryProcessor != null || cacheCtx.config().isLoadPreviousValue()) && !skipStore,
- retval,
- keepBinary,
- expiryPlc);
- }
-
- return new GridFinishedFuture<>();
- }
- catch (IgniteCheckedException e) {
- return new GridFinishedFuture<>(e);
- }
- }
-
- /**
- * Internal routine for <tt>putAll(..)</tt>
- *
- * @param cacheCtx Cache context.
- * @param keys Keys to enlist.
- * @param expiryPlc Explicitly specified expiry policy for entry.
- * @param lookup Value lookup map ({@code null} for remove).
- * @param invokeMap Map with entry processors for invoke operation.
- * @param invokeArgs Optional arguments for EntryProcessor.
- * @param retval Flag indicating whether a value should be returned.
- * @param lockOnly If {@code true}, then entry will be enlisted as noop.
- * @param filter User filters.
- * @param ret Return value.
- * @param enlisted Collection of keys enlisted into this transaction.
- * @param drPutMap DR put map (optional).
- * @param drRmvMap DR remove map (optional).
- * @param skipStore Skip store flag.
- * @param singleRmv {@code True} for single key remove operation ({@link Cache#remove(Object)}.
- * @param keepBinary Keep binary flag.
- * @param dataCenterId Optional data center ID.
- * @return Future for missing values loading.
- */
- private <K, V> IgniteInternalFuture<Void> enlistWrite(
- final GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- Collection<?> keys,
- @Nullable ExpiryPolicy expiryPlc,
- @Nullable Map<?, ?> lookup,
- @Nullable Map<?, EntryProcessor<K, V, Object>> invokeMap,
- @Nullable Object[] invokeArgs,
- final boolean retval,
- boolean lockOnly,
- final CacheEntryPredicate[] filter,
- final GridCacheReturn ret,
- Collection<KeyCacheObject> enlisted,
- @Nullable Map<KeyCacheObject, GridCacheDrInfo> drPutMap,
- @Nullable Map<KeyCacheObject, GridCacheVersion> drRmvMap,
- boolean skipStore,
- final boolean singleRmv,
- final boolean keepBinary,
- Byte dataCenterId
- ) {
- assert retval || invokeMap == null;
-
- try {
- addActiveCache(cacheCtx);
- }
- catch (IgniteCheckedException e) {
- return new GridFinishedFuture<>(e);
- }
-
- boolean rmv = lookup == null && invokeMap == null;
-
- final boolean hasFilters = !F.isEmptyOrNulls(filter) && !F.isAlwaysTrue(filter);
- final boolean needVal = singleRmv || retval || hasFilters;
- final boolean needReadVer = needVal && (serializable() && optimistic());
-
- try {
- // Set transform flag for transaction.
- if (invokeMap != null)
- transform = true;
-
- Set<KeyCacheObject> missedForLoad = null;
-
- for (Object key : keys) {
- if (key == null) {
- rollback();
-
- throw new NullPointerException("Null key.");
- }
-
- Object val = rmv || lookup == null ? null : lookup.get(key);
- EntryProcessor entryProcessor = invokeMap == null ? null : invokeMap.get(key);
-
- GridCacheVersion drVer;
- long drTtl;
- long drExpireTime;
-
- if (drPutMap != null) {
- GridCacheDrInfo info = drPutMap.get(key);
-
- assert info != null;
-
- drVer = info.version();
- drTtl = info.ttl();
- drExpireTime = info.expireTime();
- }
- else if (drRmvMap != null) {
- assert drRmvMap.get(key) != null;
-
- drVer = drRmvMap.get(key);
- drTtl = -1L;
- drExpireTime = -1L;
- }
- else if (dataCenterId != null) {
- drVer = cctx.versions().next(dataCenterId);
- drTtl = -1L;
- drExpireTime = -1L;
- }
- else {
- drVer = null;
- drTtl = -1L;
- drExpireTime = -1L;
- }
-
- if (!rmv && val == null && entryProcessor == null) {
- setRollbackOnly();
-
- throw new NullPointerException("Null value.");
- }
-
- KeyCacheObject cacheKey = cacheCtx.toCacheKeyObject(key);
-
- boolean loadMissed = enlistWriteEntry(cacheCtx,
- entryTopVer,
- cacheKey,
- val,
- entryProcessor,
- invokeArgs,
- expiryPlc,
- retval,
- lockOnly,
- filter,
- drVer,
- drTtl,
- drExpireTime,
- ret,
- enlisted,
- skipStore,
- singleRmv,
- hasFilters,
- needVal,
- needReadVer,
- keepBinary);
-
- if (loadMissed) {
- if (missedForLoad == null)
- missedForLoad = new HashSet<>();
-
- missedForLoad.add(cacheKey);
- }
- }
-
- if (missedForLoad != null) {
- AffinityTopologyVersion topVer = topologyVersionSnapshot();
-
- if (topVer == null)
- topVer = entryTopVer;
-
- return loadMissing(cacheCtx,
- topVer != null ? topVer : topologyVersion(),
- missedForLoad,
- filter,
- ret,
- needReadVer,
- singleRmv,
- hasFilters,
- /*read through*/(invokeMap != null || cacheCtx.config().isLoadPreviousValue()) && !skipStore,
- retval,
- keepBinary,
- expiryPlc);
- }
-
- return new GridFinishedFuture<>();
- }
- catch (IgniteCheckedException e) {
- return new GridFinishedFuture<>(e);
- }
- }
-
- /**
- * @param cacheCtx Cache context.
- * @param keys Keys to load.
- * @param filter Filter.
- * @param ret Return value.
- * @param needReadVer Read version flag.
- * @param singleRmv {@code True} for single remove operation.
- * @param hasFilters {@code True} if filters not empty.
- * @param readThrough Read through flag.
- * @param retval Return value flag.
- * @param expiryPlc Expiry policy.
- * @return Load future.
- */
- private IgniteInternalFuture<Void> loadMissing(
- final GridCacheContext cacheCtx,
- final AffinityTopologyVersion topVer,
- final Set<KeyCacheObject> keys,
- final CacheEntryPredicate[] filter,
- final GridCacheReturn ret,
- final boolean needReadVer,
- final boolean singleRmv,
- final boolean hasFilters,
- final boolean readThrough,
- final boolean retval,
- final boolean keepBinary,
- final ExpiryPolicy expiryPlc) {
- GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c =
- new GridInClosure3<KeyCacheObject, Object, GridCacheVersion>() {
- @Override public void apply(KeyCacheObject key,
- @Nullable Object val,
- @Nullable GridCacheVersion loadVer) {
- if (log.isDebugEnabled())
- log.debug("Loaded value from remote node [key=" + key + ", val=" + val + ']');
-
- IgniteTxEntry e = entry(new IgniteTxKey(key, cacheCtx.cacheId()));
-
- assert e != null;
-
- if (needReadVer) {
- assert loadVer != null;
-
- e.entryReadVersion(singleRmv && val != null ? SER_READ_NOT_EMPTY_VER : loadVer);
- }
-
- if (singleRmv) {
- assert !hasFilters && !retval;
- assert val == null || Boolean.TRUE.equals(val) : val;
-
- ret.set(cacheCtx, null, val != null, keepBinary);
- }
- else {
- CacheObject cacheVal = cacheCtx.toCacheObject(val);
-
- if (e.op() == TRANSFORM) {
- GridCacheVersion ver;
-
- e.readValue(cacheVal);
-
- try {
- ver = e.cached().version();
- }
- catch (GridCacheEntryRemovedException ex) {
- assert optimistic() : e;
-
- if (log.isDebugEnabled())
- log.debug("Failed to get entry version: [msg=" + ex.getMessage() + ']');
-
- ver = null;
- }
-
- addInvokeResult(e, cacheVal, ret, ver);
- }
- else {
- boolean success;
-
- if (hasFilters) {
- success = isAll(e.context(), key, cacheVal, filter);
-
- if (!success)
- e.value(cacheVal, false, false);
- }
- else
- success = true;
-
- ret.set(cacheCtx, cacheVal, success, keepBinary);
- }
- }
- }
- };
-
- return loadMissing(
- cacheCtx,
- topVer,
- readThrough,
- /*async*/true,
- keys,
- /*skipVals*/singleRmv,
- needReadVer,
- keepBinary,
- expiryPlc,
- c);
- }
-
- /**
- * @param cacheCtx Cache context.
- * @param cacheKey Key.
- * @param val Value.
- * @param entryProcessor Entry processor.
- * @param invokeArgs Optional arguments for EntryProcessor.
- * @param expiryPlc Explicitly specified expiry policy for entry.
- * @param retval Return value flag.
- * @param lockOnly Lock only flag.
- * @param filter Filter.
- * @param drVer DR version.
- * @param drTtl DR ttl.
- * @param drExpireTime DR expire time.
- * @param ret Return value.
- * @param enlisted Enlisted keys collection.
- * @param skipStore Skip store flag.
- * @param singleRmv {@code True} for single remove operation.
- * @param hasFilters {@code True} if filters not empty.
- * @param needVal {@code True} if value is needed.
- * @param needReadVer {@code True} if need read entry version.
- * @return {@code True} if entry value should be loaded.
- * @throws IgniteCheckedException If failed.
- */
- private boolean enlistWriteEntry(GridCacheContext cacheCtx,
- @Nullable AffinityTopologyVersion entryTopVer,
- final KeyCacheObject cacheKey,
- @Nullable final Object val,
- @Nullable final EntryProcessor<?, ?, ?> entryProcessor,
- @Nullable final Object[] invokeArgs,
- @Nullable final ExpiryPolicy expiryPlc,
- final boolean retval,
- final boolean lockOnly,
- final CacheEntryPredicate[] filter,
- final GridCacheVersion drVer,
- final long drTtl,
- long drExpireTime,
- final GridCacheReturn ret,
- @Nullable final Collection<KeyCacheObject> enlisted,
- boolean skipStore,
- boolean singleRmv,
- boolean hasFilters,
- final boolean needVal,
- boolean needReadVer,
- boolean keepBinary
- ) throws IgniteCheckedException {
- boolean loadMissed = false;
-
- final boolean rmv = val == null && entryProcessor == null;
-
- IgniteTxKey txKey = cacheCtx.txKey(cacheKey);
-
- IgniteTxEntry txEntry = entry(txKey);
-
- // First time access.
- if (txEntry == null) {
- while (true) {
- GridCacheEntryEx entry = entryEx(cacheCtx, txKey, entryTopVer != null ? entryTopVer : topologyVersion());
-
- try {
- entry.unswap(false);
-
- // Check if lock is being explicitly acquired by the same thread.
- if (!implicit && cctx.kernalContext().config().isCacheSanityCheckEnabled() &&
- entry.lockedByThread(threadId, xidVer)) {
- throw new IgniteCheckedException("Cannot access key within transaction if lock is " +
- "externally held [key=" + CU.value(cacheKey, cacheCtx, false) +
- ", entry=" + entry +
- ", xidVer=" + xidVer +
- ", threadId=" + threadId +
- ", locNodeId=" + cctx.localNodeId() + ']');
- }
-
- CacheObject old = null;
- GridCacheVersion readVer = null;
-
- if (optimistic() && !implicit()) {
- try {
- if (needReadVer) {
- EntryGetResult res = primaryLocal(entry) ?
- entry.innerGetVersioned(
- null,
- this,
- /*swap*/false,
- /*unmarshal*/retval || needVal,
- /*metrics*/retval,
- /*events*/retval,
- CU.subjectId(this, cctx),
- entryProcessor,
- resolveTaskName(),
- null,
- keepBinary,
- null) : null;
-
- if (res != null) {
- old = res.value();
- readVer = res.version();
- }
- }
- else {
- old = entry.innerGet(
- null,
- this,
- /*swap*/false,
- /*read-through*/false,
- /*metrics*/retval,
- /*events*/retval,
- /*temporary*/false,
- CU.subjectId(this, cctx),
- entryProcessor,
- resolveTaskName(),
- null,
- keepBinary);
- }
- }
- catch (ClusterTopologyCheckedException e) {
- entry.context().evicts().touch(entry, topologyVersion());
-
- throw e;
- }
- }
- else
- old = retval ? entry.rawGetOrUnmarshal(false) : entry.rawGet();
-
- final GridCacheOperation op = lockOnly ? NOOP : rmv ? DELETE :
- entryProcessor != null ? TRANSFORM : old != null ? UPDATE : CREATE;
-
- if (old != null && hasFilters && !filter(entry.context(), cacheKey, old, filter)) {
- ret.set(cacheCtx, old, false, keepBinary);
-
- if (!readCommitted()) {
- if (optimistic() && serializable()) {
- txEntry = addEntry(op,
- old,
- entryProcessor,
- invokeArgs,
- entry,
- expiryPlc,
- filter,
- true,
- drTtl,
- drExpireTime,
- drVer,
- skipStore,
- keepBinary);
- }
- else {
- txEntry = addEntry(READ,
- old,
- null,
- null,
- entry,
- null,
- CU.empty0(),
- false,
- -1L,
- -1L,
- null,
- skipStore,
- keepBinary);
- }
-
- txEntry.markValid();
-
- if (needReadVer) {
- assert readVer != null;
-
- txEntry.entryReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
- }
- }
-
- if (readCommitted())
- cacheCtx.evicts().touch(entry, topologyVersion());
-
- break; // While.
- }
-
- txEntry = addEntry(op,
- cacheCtx.toCacheObject(val),
- entryProcessor,
- invokeArgs,
- entry,
- expiryPlc,
- filter,
- true,
- drTtl,
- drExpireTime,
- drVer,
- skipStore,
- keepBinary);
-
- if (!implicit() && readCommitted() && !cacheCtx.offheapTiered())
- cacheCtx.evicts().touch(entry, topologyVersion());
-
- if (enlisted != null)
- enlisted.add(cacheKey);
-
- if (!pessimistic() && !implicit()) {
- txEntry.markValid();
-
- if (old == null) {
- if (needVal)
- loadMissed = true;
- else {
- assert !implicit() || !transform : this;
- assert txEntry.op() != TRANSFORM : txEntry;
-
- if (retval)
- ret.set(cacheCtx, null, true, keepBinary);
- else
- ret.success(true);
- }
- }
- else {
- if (needReadVer) {
- assert readVer != null;
-
- txEntry.entryReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
- }
-
- if (retval && !transform)
- ret.set(cacheCtx, old, true, keepBinary);
- else {
- if (txEntry.op() == TRANSFORM) {
- GridCacheVersion ver;
-
- try {
- ver = entry.version();
- }
- catch (GridCacheEntryRemovedException ex) {
- assert optimistic() : txEntry;
-
- if (log.isDebugEnabled())
- log.debug("Failed to get entry version " +
- "[err=" + ex.getMessage() + ']');
-
- ver = null;
- }
-
- addInvokeResult(txEntry, old, ret, ver);
- }
- else
- ret.success(true);
- }
- }
- }
- // Pessimistic.
- else {
- if (retval && !transform)
- ret.set(cacheCtx, old, true, keepBinary);
- else
- ret.success(true);
- }
-
- break; // While.
- }
- catch (GridCacheEntryRemovedException ignore) {
- if (log.isDebugEnabled())
- log.debug("Got removed entry in transaction putAll0 method: " + entry);
- }
- }
- }
- else {
- if (entryProcessor == null && txEntry.op() == TRANSFORM)
- throw new IgniteCheckedException("Failed to enlist write value for key (cannot have update value in " +
- "transaction after EntryProcessor is applied): " + CU.value(cacheKey, cacheCtx, false));
-
- GridCacheEntryEx entry = txEntry.cached();
-
- CacheObject v = txEntry.value();
-
- boolean del = txEntry.op() == DELETE && rmv;
-
- if (!del) {
- if (hasFilters && !filter(entry.context(), cacheKey, v, filter)) {
- ret.set(cacheCtx, v, false, keepBinary);
-
- return loadMissed;
- }
-
- GridCacheOperation op = rmv ? DELETE : entryProcessor != null ? TRANSFORM :
- v != null ? UPDATE : CREATE;
-
- txEntry = addEntry(op,
- cacheCtx.toCacheObject(val),
- entryProcessor,
- invokeArgs,
- entry,
- expiryPlc,
- filter,
- true,
- drTtl,
- drExpireTime,
- drVer,
- skipStore,
- keepBinary);
-
- if (enlisted != null)
- enlisted.add(cacheKey);
-
- if (txEntry.op() == TRANSFORM) {
- GridCacheVersion ver;
-
- try {
- ver = entry.version();
- }
- catch (GridCacheEntryRemovedException e) {
- assert optimistic() : txEntry;
-
- if (log.isDebugEnabled())
- log.debug("Failed to get entry version: [msg=" + e.getMessage() + ']');
-
- ver = null;
- }
-
- addInvokeResult(txEntry, txEntry.value(), ret, ver);
- }
- }
-
- if (!pessimistic()) {
- txEntry.markValid();
-
- if (retval && !transform)
- ret.set(cacheCtx, v, true, keepBinary);
- else
- ret.success(true);
- }
- }
-
- return loadMissed;
- }
-
- /**
- * @param cctx Cache context.
- * @param key Key.
- * @param val Value.
- * @param filter Filter.
- * @return {@code True} if filter passed.
- */
- private boolean isAll(GridCacheContext cctx,
- KeyCacheObject key,
- CacheObject val,
- CacheEntryPredicate[] filter) {
- GridCacheEntryEx e = new GridDhtDetachedCacheEntry(cctx, key, 0, val, null, 0) {
- @Nullable @Override public CacheObject peekVisibleValue() {
- return rawGet();
- }
- };
-
- for (CacheEntryPredicate p0 : filter) {
- if (p0 != null && !p0.apply(e))
- return false;
- }
-
- return true;
- }
-
- /**
- * Post lock processing for put or remove.
- *
- * @param cacheCtx Context.
- * @param keys Keys.
- * @param ret Return value.
- * @param rmv {@code True} if remove.
- * @param retval Flag to return value or not.
- * @param read {@code True} if read.
- * @param accessTtl TTL for read operation.
- * @param filter Filter to check entries.
- * @throws IgniteCheckedException If error.
- * @param computeInvoke If {@code true} computes return value for invoke operation.
- */
- @SuppressWarnings("unchecked")
- protected final void postLockWrite(
- GridCacheContext cacheCtx,
- Iterable<KeyCacheObject> keys,
- GridCacheReturn ret,
- boolean rmv,
- boolean retval,
- boolean read,
- long accessTtl,
- CacheEntryPredicate[] filter,
- boolean computeInvoke
- ) throws IgniteCheckedException {
- for (KeyCacheObject k : keys) {
- IgniteTxEntry txEntry = entry(cacheCtx.txKey(k));
-
- if (txEntry == null)
- throw new IgniteCheckedException("Transaction entry is null (most likely collection of keys passed into cache " +
- "operation was changed before operation completed) [missingKey=" + k + ", tx=" + this + ']');
-
- while (true) {
- GridCacheEntryEx cached = txEntry.cached();
-
- try {
- assert cached.detached() || cached.lockedByThread(threadId) || isRollbackOnly() :
- "Transaction lock is not acquired [entry=" + cached + ", tx=" + this +
- ", nodeId=" + cctx.localNodeId() + ", threadId=" + threadId + ']';
-
- if (log.isDebugEnabled())
- log.debug("Post lock write entry: " + cached);
-
- CacheObject v = txEntry.previousValue();
- boolean hasPrevVal = txEntry.hasPreviousValue();
-
- if (onePhaseCommit())
- filter = txEntry.filters();
-
- // If we have user-passed filter, we must read value into entry for peek().
- if (!F.isEmptyOrNulls(filter) && !F.isAlwaysTrue(filter))
- retval = true;
-
- boolean invoke = txEntry.op() == TRANSFORM;
-
- if (retval || invoke) {
- if (!cacheCtx.isNear()) {
- if (!hasPrevVal) {
- // For non-local cache should read from store after lock on primary.
- boolean readThrough = cacheCtx.isLocal() &&
- (invoke || cacheCtx.loadPreviousValue()) &&
- !txEntry.skipStore();
-
- v = cached.innerGet(
- null,
- this,
- /*swap*/true,
- readThrough,
- /*metrics*/!invoke,
- /*event*/!invoke && !dht(),
- /*temporary*/false,
- CU.subjectId(this, cctx),
- null,
- resolveTaskName(),
- null,
- txEntry.keepBinary());
- }
- }
- else {
- if (!hasPrevVal)
- v = cached.rawGetOrUnmarshal(false);
- }
-
- if (txEntry.op() == TRANSFORM) {
- if (computeInvoke) {
- GridCacheVersion ver;
-
- try {
- ver = cached.version();
- }
- catch (GridCacheEntryRemovedException e) {
- assert optimistic() : txEntry;
-
- if (log.isDebugEnabled())
- log.debug("Failed to get entry version: [msg=" + e.getMessage() + ']');
-
- ver = null;
- }
-
- addInvokeResult(txEntry, v, ret, ver);
- }
- }
- else
- ret.value(cacheCtx, v, txEntry.keepBinary());
- }
-
- boolean pass = F.isEmpty(filter) || cacheCtx.isAll(cached, filter);
-
- // For remove operation we return true only if we are removing s/t,
- // i.e. cached value is not null.
- ret.success(pass && (!retval ? !rmv || cached.hasValue() || v != null : !rmv || v != null));
-
- if (onePhaseCommit())
- txEntry.filtersPassed(pass);
-
- boolean updateTtl = read;
-
- if (pass) {
- txEntry.markValid();
-
- if (log.isDebugEnabled())
- log.debug("Filter passed in post lock for key: " + k);
- }
- else {
- // Revert operation to previous. (if no - NOOP, so entry will be unlocked).
- txEntry.setAndMarkValid(txEntry.previousOperation(), cacheCtx.toCacheObject(ret.value()));
- txEntry.filters(CU.empty0());
- txEntry.filtersSet(false);
-
- updateTtl = !cacheCtx.putIfAbsentFilter(filter);
- }
-
- if
<TRUNCATED>
[08/16] ignite git commit: Internal cache API cleanup.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index 35d0776..77272e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -17,6 +17,25 @@
package org.apache.ignite.internal.processors.igfs;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.CountDownLatch;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorResult;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
@@ -47,7 +66,7 @@ import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
import org.apache.ignite.internal.processors.cache.GridCacheInternal;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.igfs.client.IgfsClientAbstractCallable;
import org.apache.ignite.internal.processors.igfs.client.meta.IgfsClientMetaIdsForPathCallable;
import org.apache.ignite.internal.processors.igfs.client.meta.IgfsClientMetaInfoForPathCallable;
@@ -76,26 +95,6 @@ import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;
import org.jetbrains.annotations.Nullable;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.EntryProcessorResult;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.concurrent.CountDownLatch;
-
import static org.apache.ignite.events.EventType.EVT_IGFS_DIR_RENAMED;
import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_RENAMED;
@@ -604,7 +603,7 @@ public class IgfsMetaManager extends IgfsManager {
assert fileId != null;
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
// Lock file ID for this transaction.
IgfsEntryInfo oldInfo = info(fileId);
@@ -1005,7 +1004,7 @@ public class IgfsMetaManager extends IgfsManager {
srcPathIds.addExistingIds(lockIds, relaxed);
dstPathIds.addExistingIds(lockIds, relaxed);
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
// Obtain the locks.
final Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
@@ -1145,7 +1144,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteUuid trashId = IgfsUtils.randomTrashId();
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
// NB: We may lock root because its id is less than any other id:
final IgfsEntryInfo rootInfo = lockIds(IgfsUtils.ROOT_ID, trashId).get(IgfsUtils.ROOT_ID);
@@ -1268,7 +1267,7 @@ public class IgfsMetaManager extends IgfsManager {
allIds.add(trashId);
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
// Lock participants.
Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(allIds);
@@ -1345,7 +1344,7 @@ public class IgfsMetaManager extends IgfsManager {
assert listing != null;
validTxState(false);
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
Collection<IgniteUuid> res = new HashSet<>();
// Obtain all necessary locks in one hop.
@@ -1431,7 +1430,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
validTxState(false);
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
Map<IgniteUuid, IgfsEntryInfo> infos = lockIds(parentId, id);
IgfsEntryInfo victim = infos.get(id);
@@ -1517,7 +1516,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
validTxState(false);
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
IgfsEntryInfo info = updatePropertiesNonTx(fileId, props);
tx.commit();
@@ -1551,7 +1550,7 @@ public class IgfsMetaManager extends IgfsManager {
if (log.isDebugEnabled())
log.debug("Reserve file space: " + fileId);
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
// Lock file ID for this transaction.
IgfsEntryInfo oldInfo = info(fileId);
@@ -1596,7 +1595,7 @@ public class IgfsMetaManager extends IgfsManager {
if (log.isDebugEnabled())
log.debug("Update file info [fileId=" + fileId + ", proc=" + proc + ']');
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
// Lock file ID for this transaction.
IgfsEntryInfo oldInfo = info(fileId);
@@ -1658,7 +1657,7 @@ public class IgfsMetaManager extends IgfsManager {
pathIds.addSurrogateIds(lockIds);
// Start TX.
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
final Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (!pathIds.verifyIntegrity(lockInfos, relaxed))
@@ -1709,7 +1708,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
validTxState(false);
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
Object prev = val != null ? metaCache.getAndPut(sampling, val) : metaCache.getAndRemove(sampling);
tx.commit();
@@ -2602,7 +2601,7 @@ public class IgfsMetaManager extends IgfsManager {
pathIds.add(idsForPath(path));
// Start pessimistic.
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
// Lock the very first existing parents and possibly the leaf as well.
Map<IgfsPath, IgfsPath> pathToParent = new HashMap<>();
@@ -2788,7 +2787,7 @@ public class IgfsMetaManager extends IgfsManager {
*
* @return Transaction.
*/
- private IgniteInternalTx startTx() {
+ private GridNearTxLocal startTx() {
return metaCache.txStartEx(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
}
@@ -2817,7 +2816,7 @@ public class IgfsMetaManager extends IgfsManager {
pathIds.addExistingIds(lockIds, relaxed);
// Start TX.
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (secondaryFs != null && isRetryForSecondary(pathIds, lockInfos))
@@ -2927,7 +2926,7 @@ public class IgfsMetaManager extends IgfsManager {
pathIds.addSurrogateIds(lockIds);
// Start TX.
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (!pathIds.verifyIntegrity(lockInfos, relaxed))
@@ -3034,7 +3033,7 @@ public class IgfsMetaManager extends IgfsManager {
}
// Start TX.
- try (IgniteInternalTx tx = startTx()) {
+ try (GridNearTxLocal tx = startTx()) {
Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (secondaryCtx != null && isRetryForSecondary(pathIds, lockInfos))
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index 41dbdd0..a680a88 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -66,15 +66,16 @@ import org.apache.ignite.internal.processors.cache.CacheAffinityChangeMessage;
import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
import org.apache.ignite.internal.processors.cache.CacheIteratorConverter;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.query.CacheQuery;
import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.marshaller.MappingAcceptedMessage;
import org.apache.ignite.internal.processors.marshaller.MappingProposedMessage;
import org.apache.ignite.internal.processors.task.GridInternal;
import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
import org.apache.ignite.internal.util.GridEmptyIterator;
import org.apache.ignite.internal.util.GridSpinBusyLock;
+import org.apache.ignite.internal.util.SerializableTransient;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -92,7 +93,6 @@ import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.internal.util.SerializableTransient;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.JobContextResource;
import org.apache.ignite.resources.LoggerResource;
@@ -945,7 +945,7 @@ public class GridServiceProcessor extends GridProcessorAdapter {
else
nodes = null;
- try (IgniteInternalTx tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
GridServiceAssignmentsKey key = new GridServiceAssignmentsKey(cfg.getName());
GridServiceAssignments oldAssigns = (GridServiceAssignments)cache.get(key);
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java b/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
index 53e6add..c4d8a79 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
@@ -88,6 +88,8 @@ public class TestRecordingCommunicationSpi extends TcpCommunicationSpi {
blockedMsgs.add(new T2<>(node, ioMsg));
+ notifyAll();
+
return;
}
}
@@ -137,6 +139,33 @@ public class TestRecordingCommunicationSpi extends TcpCommunicationSpi {
}
/**
+ * @param cls Message class.
+ * @param nodeName Node name.
+ * @throws InterruptedException If interrupted.
+ */
+ public void waitForMessage(Class<?> cls, String nodeName) throws InterruptedException {
+ synchronized (this) {
+ while (!hasMessage(cls, nodeName))
+ wait();
+ }
+ }
+
+ /**
+ * @param cls Message class.
+ * @param nodeName Node name.
+ * @return {@code True} if has blocked message.
+ */
+ private boolean hasMessage(Class<?> cls, String nodeName) {
+ for (T2<ClusterNode, GridIoMessage> msg : blockedMsgs) {
+ if (msg.get2().message().getClass() == cls &&
+ nodeName.equals(msg.get1().attribute(ATTR_IGNITE_INSTANCE_NAME)))
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
* @param blockP Message block predicate.
*/
public void blockMessages(IgnitePredicate<GridIoMessage> blockP) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestStore.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestStore.java
index 3622964..eb30927 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestStore.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestStore.java
@@ -338,8 +338,6 @@ public final class GridCacheTestStore implements CacheStore<Integer, String> {
txs.add(tx);
- assertTrue("Unexpected tx class: " + tx.getClass(), tx instanceof TransactionProxy);
-
IgniteInternalTx tx0 = GridTestUtils.getFieldValue(tx, "tx");
if (!tx0.local())
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java
index 6e8c2a1..4fd4989 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java
@@ -33,8 +33,8 @@ import org.apache.ignite.configuration.TransactionConfiguration;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteInClosure;
@@ -210,7 +210,7 @@ public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
protected void checkStartTxSuccess(final IgniteInternalCache<Object, Object> cache) throws Exception {
- try (final IgniteInternalTx tx = CU.txStartInternal(cache.context(), cache, PESSIMISTIC, READ_COMMITTED)) {
+ try (final GridNearTxLocal tx = CU.txStartInternal(cache.context(), cache, PESSIMISTIC, READ_COMMITTED)) {
assert tx != null;
sleepForTxFailure();
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
index 17570aa..f821a45 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
@@ -18,21 +18,18 @@
package org.apache.ignite.internal.processors.cache.distributed;
import java.util.Map;
-import java.util.concurrent.Callable;
import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.transactions.Transaction;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
@@ -84,7 +81,7 @@ public class IgniteCacheSystemTransactionsSelfTest extends GridCacheAbstractSelf
utilityCache.getAndPutIfAbsent("2", "2");
- try (IgniteInternalTx itx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal itx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
assertEquals(null, utilityCache.get("1"));
assertEquals("2", utilityCache.get("2"));
assertEquals(null, utilityCache.get("3"));
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java
index b0aa67a..9ac9e31 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java
@@ -105,6 +105,11 @@ public class IgniteTxCachePrimarySyncTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return 15 * 60_000;
+ }
+
+ /** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
super.beforeTestsStarted();
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
index 702a883..91e3b26 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
@@ -37,7 +37,7 @@ import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.managers.communication.GridIoMessage;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.typedef.F;
@@ -169,14 +169,14 @@ public abstract class IgniteTxOriginatingNodeFailureAbstractSelfTest extends Gri
TransactionProxyImpl tx = (TransactionProxyImpl)txIgniteNode.transactions().txStart();
- IgniteInternalTx txEx = tx.tx();
+ GridNearTxLocal txEx = tx.tx();
assertTrue(txEx.optimistic());
cache.putAll(map);
try {
- txEx.prepareAsync().get(3, TimeUnit.SECONDS);
+ txEx.prepareNearTxLocal().get(3, TimeUnit.SECONDS);
}
catch (IgniteFutureTimeoutCheckedException ignored) {
info("Failed to wait for prepare future completion: " + partial);
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
index 3c1ae8e..4997b20 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
@@ -42,7 +42,7 @@ import org.apache.ignite.internal.managers.communication.GridIoMessage;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
@@ -349,7 +349,7 @@ public abstract class IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest
TransactionProxyImpl txProxy = (TransactionProxyImpl)tx;
- IgniteInternalTx txEx = txProxy.tx();
+ GridNearTxLocal txEx = txProxy.tx();
assertTrue(txEx.pessimistic());
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 a0a5627..7ca3914 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
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.managers.communication.GridIoMessage;
import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
@@ -210,11 +211,11 @@ public abstract class IgniteCachePrimaryNodeFailureRecoveryAbstractTest extends
log.info("Start prepare.");
- IgniteInternalTx txEx = ((TransactionProxyImpl)tx).tx();
+ GridNearTxLocal txEx = ((TransactionProxyImpl)tx).tx();
commSpi.blockMessages(ignite(2).cluster().localNode().id()); // Do not allow to finish prepare for key2.
- IgniteInternalFuture<?> prepFut = txEx.prepareAsync();
+ IgniteInternalFuture<?> prepFut = txEx.prepareNearTxLocal();
waitPrepared(ignite(1));
@@ -371,11 +372,11 @@ public abstract class IgniteCachePrimaryNodeFailureRecoveryAbstractTest extends
log.info("Start prepare.");
- IgniteInternalTx txEx = ((TransactionProxyImpl)tx).tx();
+ GridNearTxLocal txEx = ((TransactionProxyImpl)tx).tx();
commSpi.blockMessages(ignite(2).cluster().localNode().id()); // Do not allow to finish prepare for key2.
- IgniteInternalFuture<?> prepFut = txEx.prepareAsync();
+ IgniteInternalFuture<?> prepFut = txEx.prepareNearTxLocal();
waitPrepared(ignite(1));
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java
new file mode 100644
index 0000000..cfe9029
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java
@@ -0,0 +1,501 @@
+/*
+ * 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 java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import javax.cache.Cache;
+import javax.cache.configuration.Factory;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.TestRecordingCommunicationSpi;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.LoggerResource;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ *
+ */
+public class IgniteCacheTxRecoveryRollbackTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static ConcurrentHashMap<Object, Object> storeMap = new ConcurrentHashMap<>();
+
+ /** */
+ private boolean client;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setConsistentId(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
+
+ cfg.setCommunicationSpi(commSpi);
+
+ cfg.setClientMode(client);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ try {
+ for (Ignite node : G.allGrids()) {
+ Collection<IgniteInternalTx> txs = ((IgniteKernal)node).context().cache().context().tm().txs();
+
+ assertTrue("Unfinished txs [node=" + node.name() + ", txs=" + txs + ']', txs.isEmpty());
+ }
+ }
+ finally {
+ stopAllGrids();
+
+ storeMap.clear();
+
+ super.afterTest();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNearTx1Implicit() throws Exception {
+ nearTx1(null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNearTx1Optimistic() throws Exception {
+ nearTx1(OPTIMISTIC);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNearTx1Pessimistic() throws Exception {
+ nearTx1(PESSIMISTIC);
+ }
+
+ /**
+ * Stop tx near node (client2), near cache tx on client1 is either committed
+ * by primary or invalidated.
+ *
+ * @param concurrency Tx concurrency or {@code null} for implicit transaction.
+ * @throws Exception If failed.
+ */
+ private void nearTx1(final TransactionConcurrency concurrency) throws Exception {
+ startGrids(4);
+
+ Ignite srv0 = grid(0);
+
+ final IgniteCache<Integer, Integer> srvCache = srv0.createCache(cacheConfiguration(2, false, false));
+
+ awaitPartitionMapExchange();
+
+ client = true;
+
+ Ignite client1 = startGrid(4);
+ final Ignite client2 = startGrid(5);
+
+ final Integer key = primaryKey(srv0.cache(null));
+
+ final IgniteCache<Integer, Integer> cache1 =
+ client1.createNearCache(null, new NearCacheConfiguration<Integer, Integer>());
+
+ final IgniteCache<Integer, Integer> cache2 =
+ client2.createNearCache(null, new NearCacheConfiguration<Integer, Integer>());
+
+ cache1.put(key, 1);
+
+ final Integer newVal = 2;
+
+ testSpi(client2).blockMessages(GridNearTxFinishRequest.class, srv0.name());
+
+ IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ log.info("Start put, concurrency: " + concurrency);
+
+ if (concurrency != null) {
+ try (Transaction tx = client2.transactions().txStart(concurrency, REPEATABLE_READ)) {
+ cache2.put(key, newVal);
+
+ tx.commit();
+ }
+ }
+ else
+ cache2.put(key, newVal);
+
+ return null;
+ }
+ });
+
+ U.sleep(500);
+
+ assertFalse(fut.isDone());
+
+ testSpi(client2).waitForMessage(GridNearTxFinishRequest.class, srv0.name());
+
+ stopGrid(client2.name());
+
+ try {
+ fut.get();
+ }
+ catch (IgniteCheckedException ignore) {
+ // No-op.
+ }
+
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return newVal.equals(srvCache.get(key)) && newVal.equals(cache1.get(key));
+ }
+ }, 5000);
+
+ checkData(F.asMap(key, newVal));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNearTx2Implicit() throws Exception {
+ nearTx2(null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNearTx2Optimistic() throws Exception {
+ nearTx2(OPTIMISTIC);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNearTx2Pessimistic() throws Exception {
+ nearTx2(PESSIMISTIC);
+ }
+
+ /**
+ * Stop both tx near node (client2) and primary node, near cache tx on client1 is invalidated.
+ *
+ * @param concurrency Tx concurrency or {@code null} for implicit transaction.
+ * @throws Exception If failed.
+ */
+ private void nearTx2(final TransactionConcurrency concurrency) throws Exception {
+ startGrids(4);
+
+ Ignite srv0 = grid(0);
+
+ srv0.createCache(cacheConfiguration(2, false, false));
+
+ awaitPartitionMapExchange();
+
+ client = true;
+
+ Ignite client1 = startGrid(4);
+ final Ignite client2 = startGrid(5);
+
+ final Integer key = primaryKey(srv0.cache(null));
+
+ final IgniteCache<Integer, Integer> cache1 =
+ client1.createNearCache(null, new NearCacheConfiguration<Integer, Integer>());
+
+ final IgniteCache<Integer, Integer> cache2 =
+ client2.createNearCache(null, new NearCacheConfiguration<Integer, Integer>());
+
+ cache1.put(key, 1);
+
+ final Integer newVal = 2;
+
+ testSpi(client2).blockMessages(GridNearTxFinishRequest.class, srv0.name());
+
+ testSpi(srv0).blockMessages(new IgnitePredicate<GridIoMessage>() {
+ @Override public boolean apply(GridIoMessage msg) {
+ return msg.message() instanceof GridDhtTxFinishRequest;
+ }
+ });
+
+ IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ log.info("Start put, concurrency: " + concurrency);
+
+ if (concurrency != null) {
+ try (Transaction tx = client2.transactions().txStart(concurrency, REPEATABLE_READ)) {
+ cache2.put(key, newVal);
+
+ tx.commit();
+ }
+ }
+ else
+ cache2.put(key, newVal);
+
+ return null;
+ }
+ });
+
+ U.sleep(500);
+
+ assertFalse(fut.isDone());
+
+ testSpi(client2).waitForMessage(GridNearTxFinishRequest.class, srv0.name());
+
+ stopGrid(client2.name());
+ stopGrid(srv0.name());
+
+ try {
+ fut.get();
+ }
+ catch (IgniteCheckedException ignore) {
+ // No-op.
+ }
+
+ final IgniteCache<Integer, Integer> srvCache = grid(1).cache(null);
+
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return newVal.equals(srvCache.get(key)) && newVal.equals(cache1.get(key));
+ }
+ }, 5000);
+
+ checkData(F.asMap(key, newVal));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxWithStoreImplicit() throws Exception {
+ txWithStore(null, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxWithStoreOptimistic() throws Exception {
+ txWithStore(OPTIMISTIC, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxWithStorePessimistic() throws Exception {
+ txWithStore(PESSIMISTIC, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxWithStoreNoWriteThroughImplicit() throws Exception {
+ txWithStore(null, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxWithStoreNoWriteThroughOptimistic() throws Exception {
+ txWithStore(OPTIMISTIC, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxWithStoreNoWriteThroughPessimistic() throws Exception {
+ txWithStore(PESSIMISTIC, false);
+ }
+
+ /**
+ * @param concurrency Tx concurrency or {@code null} for implicit transaction.
+ * @param writeThrough Store write through flag.
+ * @throws Exception If failed.
+ */
+ private void txWithStore(final TransactionConcurrency concurrency, boolean writeThrough) throws Exception {
+ startGrids(4);
+
+ Ignite srv0 = grid(0);
+
+ IgniteCache<Integer, Integer> srv0Cache = srv0.createCache(cacheConfiguration(1, true, writeThrough));
+
+ awaitPartitionMapExchange();
+
+ final Integer key = primaryKey(srv0Cache);
+
+ srv0Cache.put(key, 1);
+
+ client = true;
+
+ Ignite client = startGrid(4);
+
+ testSpi(srv0).blockMessages(GridNearTxPrepareResponse.class, client.name());
+
+ final IgniteCache<Integer, Integer> clientCache = client.cache(null);
+
+ IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ log.info("Start put");
+
+ clientCache.put(key, 2);
+
+ return null;
+ }
+ });
+
+ U.sleep(500);
+
+ assertFalse(fut.isDone());
+
+ testSpi(srv0).waitForMessage(GridNearTxPrepareResponse.class, client.name());
+
+ stopGrid(client.name());
+
+ try {
+ fut.get();
+ }
+ catch (IgniteCheckedException ignore) {
+ // No-op.
+ }
+
+ U.sleep(1000);
+
+ if (writeThrough)
+ checkData(F.asMap(key, 1));
+ else
+ checkData(F.asMap(key, 2));
+ }
+
+ /**
+ * @param node Node.
+ * @return Node communication SPI.
+ */
+ private TestRecordingCommunicationSpi testSpi(Ignite node) {
+ return (TestRecordingCommunicationSpi)node.configuration().getCommunicationSpi();
+ }
+
+ /**
+ * @param backups Number of backups.
+ * @param store Cache store flag.
+ * @param writeThrough Store write through flag.
+ * @return Cache configuration.
+ */
+ private CacheConfiguration<Integer, Integer> cacheConfiguration(int backups, boolean store, boolean writeThrough) {
+ CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>();
+
+ ccfg.setAtomicityMode(TRANSACTIONAL);
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+ ccfg.setBackups(backups);
+ ccfg.setRebalanceMode(ASYNC);
+
+ if (store) {
+ ccfg.setWriteThrough(writeThrough);
+
+ ccfg.setCacheStoreFactory(new TestStoreFactory());
+ }
+
+ return ccfg;
+ }
+
+ /**
+ * @param expData Expected cache data.
+ */
+ private void checkData(Map<Integer, Integer> expData) {
+ assert !expData.isEmpty();
+
+ List<Ignite> nodes = G.allGrids();
+
+ assertFalse(nodes.isEmpty());
+
+ for (Ignite node : nodes) {
+ IgniteCache<Integer, Integer> cache = node.cache(null);
+
+ for (Map.Entry<Integer, Integer> e : expData.entrySet()) {
+ assertEquals("Invalid value [key=" + e.getKey() + ", node=" + node.name() + ']',
+ e.getValue(),
+ cache.get(e.getKey()));
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestStoreFactory implements Factory<CacheStore<Object, Object>> {
+ /** */
+ @LoggerResource
+ private IgniteLogger log;
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public CacheStore<Object, Object> create() {
+ return new CacheStoreAdapter() {
+ @Override public Object load(Object key) throws CacheLoaderException {
+ return storeMap.get(key);
+ }
+
+ @Override public void write(Cache.Entry entry) throws CacheWriterException {
+ log.info("Store write [key=" + entry.getKey() + ", val=" + entry.getValue() + ']');
+
+ storeMap.put(entry.getKey(), entry.getValue());
+ }
+
+ @Override public void delete(Object key) throws CacheWriterException {
+ log.info("Store delete [key=" + key + ']');
+
+ storeMap.remove(key);
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 1517672..3e56b00 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
@@ -28,7 +28,6 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -153,7 +152,7 @@ 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 prepare transaction state (i.e. call {@link GridNearTxLocal#prepare()}).
* @throws Exception If failed.
*/
private void checkSalvageAfterTimeout(TransactionConcurrency mode, boolean prepare) throws Exception {
@@ -172,7 +171,7 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
*
* @param mode Transaction mode (PESSIMISTIC, OPTIMISTIC).
* @param prepare Whether to prepare transaction state
- * (i.e. call {@link IgniteInternalTx#prepare()}).
+ * (i.e. call {@link GridNearTxLocal#prepare()}).
* @throws Exception If failed.
*/
private void checkSalvageBeforeTimeout(TransactionConcurrency mode, boolean prepare) throws Exception {
@@ -198,7 +197,7 @@ 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 prepare transaction state (i.e. call {@link GridNearTxLocal#prepare()}).
* @throws Exception If failed.
*/
private void startTxAndPutKeys(final TransactionConcurrency mode, final boolean prepare) throws Exception {
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
index 005e4a5..212675b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.Callable;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
@@ -111,9 +112,6 @@ public class TxOptimisticDeadlockDetectionTest extends GridCommonAbstractTest {
cfg.setClientMode(client);
- // Test spi blocks message send, this can cause hang with striped pool.
- cfg.setStripedPoolSize(-1);
-
return cfg;
}
@@ -555,15 +553,25 @@ public class TxOptimisticDeadlockDetectionTest extends GridCommonAbstractTest {
GridCacheVersion txId = req.version();
- if (TX_IDS.contains(txId)) {
- while (TX_IDS.size() < TX_CNT) {
- try {
- U.sleep(50);
- }
- catch (IgniteInterruptedCheckedException e) {
- e.printStackTrace();
+ if (TX_IDS.contains(txId) && TX_IDS.size() < TX_CNT) {
+ GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ while (TX_IDS.size() < TX_CNT) {
+ try {
+ U.sleep(50);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ TestCommunicationSpi.super.sendMessage(node, msg, ackC);
+
+ return null;
}
- }
+ });
+
+ return;
}
}
else if (msg0 instanceof GridNearTxPrepareResponse) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java
index fba78c8..16596ed 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java
@@ -34,7 +34,7 @@ import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.lang.GridAbsPredicateX;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
@@ -118,7 +118,7 @@ public class IgfsBlockMessageSystemPoolStarvationSelfTest extends IgfsCommonAbst
@Override public Void call() throws Exception {
GridCacheAdapter dataCache = dataCache(attacker);
- try (IgniteInternalTx tx = dataCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+ try (GridNearTxLocal tx = dataCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
dataCache.put(DATA_KEY, 0);
txStartLatch.countDown();
@@ -257,7 +257,7 @@ public class IgfsBlockMessageSystemPoolStarvationSelfTest extends IgfsCommonAbst
cfg.setLocalHost("127.0.0.1");
cfg.setConnectorConfiguration(null);
- cfg.setStripedPoolSize(0);
+ cfg.setStripedPoolSize(2);
cfg.setSystemThreadPoolSize(2);
cfg.setRebalanceThreadPoolSize(1);
cfg.setPublicThreadPoolSize(1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java
index 0513786..1901283 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java
@@ -44,7 +44,8 @@ public class IgniteCacheRestartTestSuite2 extends TestSuite {
suite.addTestSuite(IgniteCachePutAllRestartTest.class);
suite.addTestSuite(GridCachePutAllFailoverSelfTest.class);
- suite.addTestSuite(IgniteBinaryMetadataUpdateNodeRestartTest.class);
+ // TODO IGNITE-4768.
+ //suite.addTestSuite(IgniteBinaryMetadataUpdateNodeRestartTest.class);
suite.addTestSuite(IgniteCacheGetRestartTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java
index 7363c7c..7bd7797 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheCo
import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePartitionedNearDisabledPrimaryNodeFailureRecoveryTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePartitionedPrimaryNodeFailureRecoveryTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePartitionedTwoBackupsPrimaryNodeFailureRecoveryTest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheTxRecoveryRollbackTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearTxPessimisticOriginatingNodeFailureSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxOriginatingNodeFailureSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxPessimisticOriginatingNodeFailureSelfTest;
@@ -54,6 +55,8 @@ public class IgniteCacheTxRecoverySelfTestSuite extends TestSuite {
suite.addTestSuite(GridCacheNearTxPessimisticOriginatingNodeFailureSelfTest.class);
suite.addTestSuite(GridCacheReplicatedTxPessimisticOriginatingNodeFailureSelfTest.class);
+ suite.addTestSuite(IgniteCacheTxRecoveryRollbackTest.class);
+
return suite;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
index bbb1d4e..1e2aded 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
@@ -22,8 +22,8 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.GridLeanSet;
-import org.apache.ignite.transactions.Transaction;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cache.spi.access.SoftLock;
@@ -250,15 +250,15 @@ public class HibernateReadWriteAccessStrategy extends HibernateAccessStrategyAda
if (ctx.unlocked(key)) { // Finish transaction if last key is unlocked.
txCtx.remove();
- Transaction tx = cache.tx();
+ GridNearTxLocal tx = cache.tx();
assert tx != null;
try {
- tx.commit();
+ tx.proxy().commit();
}
finally {
- tx.close();
+ tx.proxy().close();
}
assert cache.tx() == null;
@@ -275,10 +275,10 @@ public class HibernateReadWriteAccessStrategy extends HibernateAccessStrategyAda
if (ctx != null) {
txCtx.remove();
- Transaction tx = cache.tx();
+ GridNearTxLocal tx = cache.tx();
if (tx != null)
- tx.rollback();
+ tx.proxy().rollback();
}
}
catch (IgniteException e) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 f581ebb..5047491 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
@@ -27,6 +27,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.jta.CacheTmLookup;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.TransactionConfiguration;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.lifecycle.LifecycleAware;
import org.jetbrains.annotations.Nullable;
@@ -151,7 +152,7 @@ public class CacheJtaManager extends CacheJtaManagerAdapter {
Transaction jtaTx = jtaTm.getTransaction();
if (jtaTx != null) {
- IgniteInternalTx tx = cctx.tm().userTx();
+ GridNearTxLocal tx = cctx.tm().userTx();
if (tx == null) {
TransactionConfiguration tCfg = cctx.kernalContext().config()
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaResource.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaResource.java b/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaResource.java
index f43981e..649f7c4 100644
--- a/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaResource.java
+++ b/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaResource.java
@@ -27,7 +27,7 @@ import javax.transaction.xa.Xid;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.transactions.TransactionState;
@@ -51,7 +51,7 @@ final class CacheJtaResource implements XAResource, Synchronization {
private static final Xid[] NO_XID = new Xid[] {};
/** Cache transaction. */
- private IgniteInternalTx cacheTx;
+ private GridNearTxLocal cacheTx;
/** */
private Xid xid;
@@ -60,7 +60,7 @@ final class CacheJtaResource implements XAResource, Synchronization {
* @param cacheTx Cache jta.
* @param ctx Kernal context.
*/
- public CacheJtaResource(IgniteInternalTx cacheTx, GridKernalContext ctx) {
+ CacheJtaResource(GridNearTxLocal cacheTx, GridKernalContext ctx) {
assert cacheTx != null;
assert ctx != null;
@@ -291,7 +291,7 @@ final class CacheJtaResource implements XAResource, Synchronization {
*
* @return {@code true} if jta was already committed or rolled back.
*/
- public boolean isFinished() {
+ boolean isFinished() {
TransactionState state = cacheTx.state();
return state == COMMITTED || state == ROLLED_BACK;
[12/16] ignite git commit: Internal cache API cleanup.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/decb0c7a/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 8ed749c..81606d4 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
@@ -18,24 +18,37 @@
package org.apache.ignite.internal.processors.cache.distributed.near;
import java.io.Externalizable;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
+import javax.cache.Cache;
+import javax.cache.CacheException;
import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.processor.EntryProcessor;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.NodeStoppingException;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
+import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.CacheOperationContext;
+import org.apache.ignite.internal.processors.cache.EntryGetResult;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
-import org.apache.ignite.internal.processors.cache.EntryGetResult;
import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate;
import org.apache.ignite.internal.processors.cache.GridCacheMvccFuture;
+import org.apache.ignite.internal.processors.cache.GridCacheOperation;
import org.apache.ignite.internal.processors.cache.GridCacheReturn;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
@@ -46,31 +59,52 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheE
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocalAdapter;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture;
+import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtDetachedCacheEntry;
+import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
+import org.apache.ignite.internal.processors.cache.transactions.TransactionProxy;
+import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException;
+import org.apache.ignite.internal.util.GridLeanMap;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.GridClosureException;
import org.apache.ignite.internal.util.lang.GridInClosure3;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.C1;
+import org.apache.ignite.internal.util.typedef.C2;
import org.apache.ignite.internal.util.typedef.CI1;
+import org.apache.ignite.internal.util.typedef.CI2;
+import org.apache.ignite.internal.util.typedef.CX1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiClosure;
+import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.plugin.security.SecurityPermission;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;
import org.apache.ignite.transactions.TransactionState;
import org.jetbrains.annotations.Nullable;
+import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ;
+import static org.apache.ignite.internal.processors.cache.GridCacheOperation.CREATE;
+import static org.apache.ignite.internal.processors.cache.GridCacheOperation.DELETE;
+import static org.apache.ignite.internal.processors.cache.GridCacheOperation.NOOP;
+import static org.apache.ignite.internal.processors.cache.GridCacheOperation.READ;
+import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRANSFORM;
+import static org.apache.ignite.internal.processors.cache.GridCacheOperation.UPDATE;
+import static org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry.SER_READ_EMPTY_ENTRY_VER;
+import static org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry.SER_READ_NOT_EMPTY_VER;
import static org.apache.ignite.transactions.TransactionState.COMMITTED;
import static org.apache.ignite.transactions.TransactionState.COMMITTING;
import static org.apache.ignite.transactions.TransactionState.PREPARED;
@@ -83,7 +117,7 @@ import static org.apache.ignite.transactions.TransactionState.UNKNOWN;
* Replicated user transaction.
*/
@SuppressWarnings("unchecked")
-public class GridNearTxLocal extends GridDhtTxLocalAdapter {
+public class GridNearTxLocal extends GridDhtTxLocalAdapter implements AutoCloseable {
/** */
private static final long serialVersionUID = 0L;
@@ -135,6 +169,13 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
/** */
private boolean hasRemoteLocks;
+ /** If this transaction contains transform entries. */
+ protected boolean transform;
+
+ /** */
+ @GridToStringExclude
+ private TransactionProxyImpl proxy;
+
/**
* Empty constructor required for {@link Externalizable}.
*/
@@ -244,14 +285,14 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
/**
* Marks transaction to check if commit on backup.
*/
- public void markForBackupCheck() {
+ void markForBackupCheck() {
needCheckBackup = true;
}
/**
* @return If need to check tx commit on backup.
*/
- public boolean onNeedCheckBackup() {
+ boolean onNeedCheckBackup() {
Boolean check = needCheckBackup;
if (check != null && check) {
@@ -260,52 +301,2127 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
return true;
}
- return false;
- }
+ return false;
+ }
+
+ /**
+ * @return If backup check was requested.
+ */
+ boolean needCheckBackup() {
+ return needCheckBackup != null;
+ }
+
+ /**
+ * @return {@code True} if transaction contains at least one near cache key mapped to the local node.
+ */
+ public boolean nearLocallyMapped() {
+ return nearLocallyMapped;
+ }
+
+ /**
+ * @param nearLocallyMapped {@code True} if transaction contains near key mapped to the local node.
+ */
+ void nearLocallyMapped(boolean nearLocallyMapped) {
+ this.nearLocallyMapped = nearLocallyMapped;
+ }
+
+ /**
+ * @return {@code True} if transaction contains colocated key mapped to the local node.
+ */
+ public boolean colocatedLocallyMapped() {
+ return colocatedLocallyMapped;
+ }
+
+ /**
+ * @param colocatedLocallyMapped {@code True} if transaction contains colocated key mapped to the local node.
+ */
+ public void colocatedLocallyMapped(boolean colocatedLocallyMapped) {
+ this.colocatedLocallyMapped = colocatedLocallyMapped;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean ownsLockUnsafe(GridCacheEntryEx entry) {
+ return entry.detached() || super.ownsLockUnsafe(entry);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean ownsLock(GridCacheEntryEx entry) throws GridCacheEntryRemovedException {
+ return entry.detached() || super.ownsLock(entry);
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param map Map to put.
+ * @param retval Flag indicating whether a value should be returned.
+ * @return Future for put operation.
+ */
+ @SuppressWarnings("unchecked")
+ public <K, V> IgniteInternalFuture<GridCacheReturn> putAllAsync(
+ GridCacheContext cacheCtx,
+ @Nullable AffinityTopologyVersion entryTopVer,
+ Map<? extends K, ? extends V> map,
+ boolean retval
+ ) {
+ return (IgniteInternalFuture<GridCacheReturn>)putAllAsync0(cacheCtx,
+ entryTopVer,
+ map,
+ null,
+ null,
+ null,
+ retval);
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param key Key.
+ * @param val Value.
+ * @param retval Return value flag.
+ * @param filter Filter.
+ * @return Future for put operation.
+ */
+ public final <K, V> IgniteInternalFuture<GridCacheReturn> putAsync(
+ GridCacheContext cacheCtx,
+ @Nullable AffinityTopologyVersion entryTopVer,
+ K key,
+ V val,
+ boolean retval,
+ CacheEntryPredicate filter) {
+ return putAsync0(cacheCtx,
+ entryTopVer,
+ key,
+ val,
+ null,
+ null,
+ retval,
+ filter);
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param key Key.
+ * @param entryProcessor Entry processor.
+ * @param invokeArgs Optional arguments for entry processor.
+ * @return Operation future.
+ */
+ public <K, V> IgniteInternalFuture<GridCacheReturn> invokeAsync(GridCacheContext cacheCtx,
+ @Nullable AffinityTopologyVersion entryTopVer,
+ K key,
+ EntryProcessor<K, V, Object> entryProcessor,
+ Object... invokeArgs) {
+ return (IgniteInternalFuture)putAsync0(cacheCtx,
+ entryTopVer,
+ key,
+ null,
+ entryProcessor,
+ invokeArgs,
+ true,
+ null);
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param map Entry processors map.
+ * @param invokeArgs Optional arguments for entry processor.
+ * @return Operation future.
+ */
+ @SuppressWarnings("unchecked")
+ public <K, V, T> IgniteInternalFuture<GridCacheReturn> invokeAsync(
+ GridCacheContext cacheCtx,
+ @Nullable AffinityTopologyVersion entryTopVer,
+ @Nullable Map<? extends K, ? extends EntryProcessor<K, V, Object>> map,
+ Object... invokeArgs
+ ) {
+ return (IgniteInternalFuture<GridCacheReturn>)putAllAsync0(cacheCtx,
+ entryTopVer,
+ null,
+ map,
+ invokeArgs,
+ null,
+ true);
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param drMap DR map to put.
+ * @return Future for DR put operation.
+ */
+ public IgniteInternalFuture<?> putAllDrAsync(
+ GridCacheContext cacheCtx,
+ Map<KeyCacheObject, GridCacheDrInfo> drMap
+ ) {
+ Map<KeyCacheObject, Object> map = F.viewReadOnly(drMap, new IgniteClosure<GridCacheDrInfo, Object>() {
+ @Override public Object apply(GridCacheDrInfo val) {
+ return val.value();
+ }
+ });
+
+ return this.<Object, Object>putAllAsync0(cacheCtx,
+ null,
+ map,
+ null,
+ null,
+ drMap,
+ false);
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param drMap DR map.
+ * @return Future for asynchronous remove.
+ */
+ public IgniteInternalFuture<?> removeAllDrAsync(
+ GridCacheContext cacheCtx,
+ Map<KeyCacheObject, GridCacheVersion> drMap
+ ) {
+ return removeAllAsync0(cacheCtx, null, null, drMap, false, null, false);
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param keys Keys to remove.
+ * @param retval Flag indicating whether a value should be returned.
+ * @param filter Filter.
+ * @param singleRmv {@code True} for single key remove operation ({@link Cache#remove(Object)}.
+ * @return Future for asynchronous remove.
+ */
+ public <K, V> IgniteInternalFuture<GridCacheReturn> removeAllAsync(
+ GridCacheContext cacheCtx,
+ @Nullable AffinityTopologyVersion entryTopVer,
+ Collection<? extends K> keys,
+ boolean retval,
+ CacheEntryPredicate filter,
+ boolean singleRmv
+ ) {
+ return removeAllAsync0(cacheCtx, entryTopVer, keys, null, retval, filter, singleRmv);
+ }
+
+ /**
+ * Internal method for single update operation.
+ *
+ * @param cacheCtx Cache context.
+ * @param key Key.
+ * @param val Value.
+ * @param entryProcessor Entry processor.
+ * @param invokeArgs Optional arguments for EntryProcessor.
+ * @param retval Return value flag.
+ * @param filter Filter.
+ * @return Operation future.
+ */
+ private <K, V> IgniteInternalFuture putAsync0(
+ final GridCacheContext cacheCtx,
+ @Nullable AffinityTopologyVersion entryTopVer,
+ K key,
+ @Nullable V val,
+ @Nullable EntryProcessor<K, V, Object> entryProcessor,
+ @Nullable final Object[] invokeArgs,
+ final boolean retval,
+ @Nullable final CacheEntryPredicate filter
+ ) {
+ assert key != null;
+
+ try {
+ beforePut(cacheCtx, retval);
+
+ final GridCacheReturn ret = new GridCacheReturn(localResult(), false);
+
+ CacheOperationContext opCtx = cacheCtx.operationContextPerCall();
+
+ final Byte dataCenterId = opCtx != null ? opCtx.dataCenterId() : null;
+
+ KeyCacheObject cacheKey = cacheCtx.toCacheKeyObject(key);
+
+ boolean keepBinary = opCtx != null && opCtx.isKeepBinary();
+
+ final CacheEntryPredicate[] filters = CU.filterArray(filter);
+
+ final IgniteInternalFuture<Void> loadFut = enlistWrite(
+ cacheCtx,
+ entryTopVer,
+ cacheKey,
+ val,
+ opCtx != null ? opCtx.expiry() : null,
+ entryProcessor,
+ invokeArgs,
+ retval,
+ /*lockOnly*/false,
+ filters,
+ ret,
+ opCtx != null && opCtx.skipStore(),
+ /*singleRmv*/false,
+ keepBinary,
+ dataCenterId);
+
+ if (pessimistic()) {
+ assert loadFut == null || loadFut.isDone() : loadFut;
+
+ if (loadFut != null)
+ loadFut.get();
+
+ final Collection<KeyCacheObject> enlisted = Collections.singleton(cacheKey);
+
+ if (log.isDebugEnabled())
+ log.debug("Before acquiring transaction lock for put on key: " + enlisted);
+
+ long timeout = remainingTime();
+
+ if (timeout == -1)
+ return new GridFinishedFuture<>(timeoutException());
+
+ IgniteInternalFuture<Boolean> fut = cacheCtx.cache().txLockAsync(enlisted,
+ timeout,
+ this,
+ /*read*/entryProcessor != null, // Needed to force load from store.
+ retval,
+ isolation,
+ isInvalidate(),
+ -1L,
+ -1L);
+
+ PLC1<GridCacheReturn> plc1 = new PLC1<GridCacheReturn>(ret) {
+ @Override public GridCacheReturn postLock(GridCacheReturn ret)
+ throws IgniteCheckedException
+ {
+ if (log.isDebugEnabled())
+ log.debug("Acquired transaction lock for put on keys: " + enlisted);
+
+ postLockWrite(cacheCtx,
+ enlisted,
+ ret,
+ /*remove*/false,
+ retval,
+ /*read*/false,
+ -1L,
+ filters,
+ /*computeInvoke*/true);
+
+ return ret;
+ }
+ };
+
+ if (fut.isDone()) {
+ try {
+ return nonInterruptable(plc1.apply(fut.get(), null));
+ }
+ catch (GridClosureException e) {
+ return new GridFinishedFuture<>(e.unwrap());
+ }
+ catch (IgniteCheckedException e) {
+ try {
+ return nonInterruptable(plc1.apply(false, e));
+ }
+ catch (Exception e1) {
+ return new GridFinishedFuture<>(e1);
+ }
+ }
+ }
+ else {
+ return nonInterruptable(new GridEmbeddedFuture<>(
+ fut,
+ plc1
+ ));
+ }
+ }
+ else
+ return optimisticPutFuture(cacheCtx, loadFut, ret, keepBinary);
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture(e);
+ }
+ catch (RuntimeException e) {
+ onException();
+
+ throw e;
+ }
+ }
+
+ /**
+ * Internal method for all put and transform operations. Only one of {@code map}, {@code transformMap}
+ * maps must be non-null.
+ *
+ * @param cacheCtx Context.
+ * @param map Key-value map to store.
+ * @param invokeMap Invoke map.
+ * @param invokeArgs Optional arguments for EntryProcessor.
+ * @param drMap DR map.
+ * @param retval Key-transform value map to store.
+ * @return Operation future.
+ */
+ @SuppressWarnings("unchecked")
+ private <K, V> IgniteInternalFuture putAllAsync0(
+ final GridCacheContext cacheCtx,
+ @Nullable AffinityTopologyVersion entryTopVer,
+ @Nullable Map<? extends K, ? extends V> map,
+ @Nullable Map<? extends K, ? extends EntryProcessor<K, V, Object>> invokeMap,
+ @Nullable final Object[] invokeArgs,
+ @Nullable Map<KeyCacheObject, GridCacheDrInfo> drMap,
+ final boolean retval
+ ) {
+ try {
+ beforePut(cacheCtx, retval);
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture(e);
+ }
+
+ final CacheOperationContext opCtx = cacheCtx.operationContextPerCall();
+
+ final Byte dataCenterId;
+
+ if (opCtx != null && opCtx.hasDataCenterId()) {
+ assert drMap == null : drMap;
+ assert map != null || invokeMap != null;
+
+ dataCenterId = opCtx.dataCenterId();
+ }
+ else
+ dataCenterId = null;
+
+ // Cached entry may be passed only from entry wrapper.
+ final Map<?, ?> map0 = map;
+ final Map<?, EntryProcessor<K, V, Object>> invokeMap0 = (Map<K, EntryProcessor<K, V, Object>>)invokeMap;
+
+ if (log.isDebugEnabled())
+ log.debug("Called putAllAsync(...) [tx=" + this + ", map=" + map0 + ", retval=" + retval + "]");
+
+ assert map0 != null || invokeMap0 != null;
+
+ final GridCacheReturn ret = new GridCacheReturn(localResult(), false);
+
+ if (F.isEmpty(map0) && F.isEmpty(invokeMap0)) {
+ if (implicit())
+ try {
+ commit();
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture<>(e);
+ }
+
+ return new GridFinishedFuture<>(ret.success(true));
+ }
+
+ try {
+ Set<?> keySet = map0 != null ? map0.keySet() : invokeMap0.keySet();
+
+ final Collection<KeyCacheObject> enlisted = new ArrayList<>(keySet.size());
+
+ final boolean keepBinary = opCtx != null && opCtx.isKeepBinary();
+
+ final IgniteInternalFuture<Void> loadFut = enlistWrite(
+ cacheCtx,
+ entryTopVer,
+ keySet,
+ opCtx != null ? opCtx.expiry() : null,
+ map0,
+ invokeMap0,
+ invokeArgs,
+ retval,
+ false,
+ CU.filterArray(null),
+ ret,
+ enlisted,
+ drMap,
+ null,
+ opCtx != null && opCtx.skipStore(),
+ false,
+ keepBinary,
+ dataCenterId);
+
+ if (pessimistic()) {
+ assert loadFut == null || loadFut.isDone() : loadFut;
+
+ if (loadFut != null) {
+ try {
+ loadFut.get();
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture(e);
+ }
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Before acquiring transaction lock for put on keys: " + enlisted);
+
+ long timeout = remainingTime();
+
+ if (timeout == -1)
+ return new GridFinishedFuture<>(timeoutException());
+
+ IgniteInternalFuture<Boolean> fut = cacheCtx.cache().txLockAsync(enlisted,
+ timeout,
+ this,
+ /*read*/invokeMap != null, // Needed to force load from store.
+ retval,
+ isolation,
+ isInvalidate(),
+ -1L,
+ -1L);
+
+ PLC1<GridCacheReturn> plc1 = new PLC1<GridCacheReturn>(ret) {
+ @Override public GridCacheReturn postLock(GridCacheReturn ret)
+ throws IgniteCheckedException
+ {
+ if (log.isDebugEnabled())
+ log.debug("Acquired transaction lock for put on keys: " + enlisted);
+
+ postLockWrite(cacheCtx,
+ enlisted,
+ ret,
+ /*remove*/false,
+ retval,
+ /*read*/false,
+ -1L,
+ CU.filterArray(null),
+ /*computeInvoke*/true);
+
+ return ret;
+ }
+ };
+
+ if (fut.isDone()) {
+ try {
+ return nonInterruptable(plc1.apply(fut.get(), null));
+ }
+ catch (GridClosureException e) {
+ return new GridFinishedFuture<>(e.unwrap());
+ }
+ catch (IgniteCheckedException e) {
+ try {
+ return nonInterruptable(plc1.apply(false, e));
+ }
+ catch (Exception e1) {
+ return new GridFinishedFuture<>(e1);
+ }
+ }
+ }
+ else {
+ return nonInterruptable(new GridEmbeddedFuture<>(
+ fut,
+ plc1
+ ));
+ }
+ }
+ else
+ return optimisticPutFuture(cacheCtx, loadFut, ret, keepBinary);
+ }
+ catch (RuntimeException e) {
+ onException();
+
+ throw e;
+ }
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param cacheKey Key to enlist.
+ * @param val Value.
+ * @param expiryPlc Explicitly specified expiry policy for entry.
+ * @param entryProcessor Entry processor (for invoke operation).
+ * @param invokeArgs Optional arguments for EntryProcessor.
+ * @param retval Flag indicating whether a value should be returned.
+ * @param lockOnly If {@code true}, then entry will be enlisted as noop.
+ * @param filter User filters.
+ * @param ret Return value.
+ * @param skipStore Skip store flag.
+ * @param singleRmv {@code True} for single key remove operation ({@link Cache#remove(Object)}.
+ * @return Future for entry values loading.
+ */
+ private <K, V> IgniteInternalFuture<Void> enlistWrite(
+ final GridCacheContext cacheCtx,
+ @Nullable AffinityTopologyVersion entryTopVer,
+ KeyCacheObject cacheKey,
+ Object val,
+ @Nullable ExpiryPolicy expiryPlc,
+ @Nullable EntryProcessor<K, V, Object> entryProcessor,
+ @Nullable Object[] invokeArgs,
+ final boolean retval,
+ boolean lockOnly,
+ final CacheEntryPredicate[] filter,
+ final GridCacheReturn ret,
+ boolean skipStore,
+ final boolean singleRmv,
+ boolean keepBinary,
+ Byte dataCenterId) {
+ try {
+ addActiveCache(cacheCtx);
+
+ final boolean hasFilters = !F.isEmptyOrNulls(filter) && !F.isAlwaysTrue(filter);
+ final boolean needVal = singleRmv || retval || hasFilters;
+ final boolean needReadVer = needVal && (serializable() && optimistic());
+
+ if (entryProcessor != null)
+ transform = true;
+
+ GridCacheVersion drVer = dataCenterId != null ? cctx.versions().next(dataCenterId) : null;
+
+ boolean loadMissed = enlistWriteEntry(cacheCtx,
+ entryTopVer,
+ cacheKey,
+ val,
+ entryProcessor,
+ invokeArgs,
+ expiryPlc,
+ retval,
+ lockOnly,
+ filter,
+ /*drVer*/drVer,
+ /*drTtl*/-1L,
+ /*drExpireTime*/-1L,
+ ret,
+ /*enlisted*/null,
+ skipStore,
+ singleRmv,
+ hasFilters,
+ needVal,
+ needReadVer,
+ keepBinary);
+
+ if (loadMissed) {
+ AffinityTopologyVersion topVer = topologyVersionSnapshot();
+
+ if (topVer == null)
+ topVer = entryTopVer;
+
+ return loadMissing(cacheCtx,
+ topVer != null ? topVer : topologyVersion(),
+ Collections.singleton(cacheKey),
+ filter,
+ ret,
+ needReadVer,
+ singleRmv,
+ hasFilters,
+ /*read through*/(entryProcessor != null || cacheCtx.config().isLoadPreviousValue()) && !skipStore,
+ retval,
+ keepBinary,
+ expiryPlc);
+ }
+
+ return new GridFinishedFuture<>();
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture<>(e);
+ }
+ }
+
+ /**
+ * Internal routine for <tt>putAll(..)</tt>
+ *
+ * @param cacheCtx Cache context.
+ * @param keys Keys to enlist.
+ * @param expiryPlc Explicitly specified expiry policy for entry.
+ * @param lookup Value lookup map ({@code null} for remove).
+ * @param invokeMap Map with entry processors for invoke operation.
+ * @param invokeArgs Optional arguments for EntryProcessor.
+ * @param retval Flag indicating whether a value should be returned.
+ * @param lockOnly If {@code true}, then entry will be enlisted as noop.
+ * @param filter User filters.
+ * @param ret Return value.
+ * @param enlisted Collection of keys enlisted into this transaction.
+ * @param drPutMap DR put map (optional).
+ * @param drRmvMap DR remove map (optional).
+ * @param skipStore Skip store flag.
+ * @param singleRmv {@code True} for single key remove operation ({@link Cache#remove(Object)}.
+ * @param keepBinary Keep binary flag.
+ * @param dataCenterId Optional data center ID.
+ * @return Future for missing values loading.
+ */
+ private <K, V> IgniteInternalFuture<Void> enlistWrite(
+ final GridCacheContext cacheCtx,
+ @Nullable AffinityTopologyVersion entryTopVer,
+ Collection<?> keys,
+ @Nullable ExpiryPolicy expiryPlc,
+ @Nullable Map<?, ?> lookup,
+ @Nullable Map<?, EntryProcessor<K, V, Object>> invokeMap,
+ @Nullable Object[] invokeArgs,
+ final boolean retval,
+ boolean lockOnly,
+ final CacheEntryPredicate[] filter,
+ final GridCacheReturn ret,
+ Collection<KeyCacheObject> enlisted,
+ @Nullable Map<KeyCacheObject, GridCacheDrInfo> drPutMap,
+ @Nullable Map<KeyCacheObject, GridCacheVersion> drRmvMap,
+ boolean skipStore,
+ final boolean singleRmv,
+ final boolean keepBinary,
+ Byte dataCenterId
+ ) {
+ assert retval || invokeMap == null;
+
+ try {
+ addActiveCache(cacheCtx);
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture<>(e);
+ }
+
+ boolean rmv = lookup == null && invokeMap == null;
+
+ final boolean hasFilters = !F.isEmptyOrNulls(filter) && !F.isAlwaysTrue(filter);
+ final boolean needVal = singleRmv || retval || hasFilters;
+ final boolean needReadVer = needVal && (serializable() && optimistic());
+
+ try {
+ // Set transform flag for transaction.
+ if (invokeMap != null)
+ transform = true;
+
+ Set<KeyCacheObject> missedForLoad = null;
+
+ for (Object key : keys) {
+ if (key == null) {
+ rollback();
+
+ throw new NullPointerException("Null key.");
+ }
+
+ Object val = rmv || lookup == null ? null : lookup.get(key);
+ EntryProcessor entryProcessor = invokeMap == null ? null : invokeMap.get(key);
+
+ GridCacheVersion drVer;
+ long drTtl;
+ long drExpireTime;
+
+ if (drPutMap != null) {
+ GridCacheDrInfo info = drPutMap.get(key);
+
+ assert info != null;
+
+ drVer = info.version();
+ drTtl = info.ttl();
+ drExpireTime = info.expireTime();
+ }
+ else if (drRmvMap != null) {
+ assert drRmvMap.get(key) != null;
+
+ drVer = drRmvMap.get(key);
+ drTtl = -1L;
+ drExpireTime = -1L;
+ }
+ else if (dataCenterId != null) {
+ drVer = cctx.versions().next(dataCenterId);
+ drTtl = -1L;
+ drExpireTime = -1L;
+ }
+ else {
+ drVer = null;
+ drTtl = -1L;
+ drExpireTime = -1L;
+ }
+
+ if (!rmv && val == null && entryProcessor == null) {
+ setRollbackOnly();
+
+ throw new NullPointerException("Null value.");
+ }
+
+ KeyCacheObject cacheKey = cacheCtx.toCacheKeyObject(key);
+
+ boolean loadMissed = enlistWriteEntry(cacheCtx,
+ entryTopVer,
+ cacheKey,
+ val,
+ entryProcessor,
+ invokeArgs,
+ expiryPlc,
+ retval,
+ lockOnly,
+ filter,
+ drVer,
+ drTtl,
+ drExpireTime,
+ ret,
+ enlisted,
+ skipStore,
+ singleRmv,
+ hasFilters,
+ needVal,
+ needReadVer,
+ keepBinary);
+
+ if (loadMissed) {
+ if (missedForLoad == null)
+ missedForLoad = new HashSet<>();
+
+ missedForLoad.add(cacheKey);
+ }
+ }
+
+ if (missedForLoad != null) {
+ AffinityTopologyVersion topVer = topologyVersionSnapshot();
+
+ if (topVer == null)
+ topVer = entryTopVer;
+
+ return loadMissing(cacheCtx,
+ topVer != null ? topVer : topologyVersion(),
+ missedForLoad,
+ filter,
+ ret,
+ needReadVer,
+ singleRmv,
+ hasFilters,
+ /*read through*/(invokeMap != null || cacheCtx.config().isLoadPreviousValue()) && !skipStore,
+ retval,
+ keepBinary,
+ expiryPlc);
+ }
+
+ return new GridFinishedFuture<>();
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture<>(e);
+ }
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param cacheKey Key.
+ * @param val Value.
+ * @param entryProcessor Entry processor.
+ * @param invokeArgs Optional arguments for EntryProcessor.
+ * @param expiryPlc Explicitly specified expiry policy for entry.
+ * @param retval Return value flag.
+ * @param lockOnly Lock only flag.
+ * @param filter Filter.
+ * @param drVer DR version.
+ * @param drTtl DR ttl.
+ * @param drExpireTime DR expire time.
+ * @param ret Return value.
+ * @param enlisted Enlisted keys collection.
+ * @param skipStore Skip store flag.
+ * @param singleRmv {@code True} for single remove operation.
+ * @param hasFilters {@code True} if filters not empty.
+ * @param needVal {@code True} if value is needed.
+ * @param needReadVer {@code True} if need read entry version.
+ * @return {@code True} if entry value should be loaded.
+ * @throws IgniteCheckedException If failed.
+ */
+ private boolean enlistWriteEntry(GridCacheContext cacheCtx,
+ @Nullable AffinityTopologyVersion entryTopVer,
+ final KeyCacheObject cacheKey,
+ @Nullable final Object val,
+ @Nullable final EntryProcessor<?, ?, ?> entryProcessor,
+ @Nullable final Object[] invokeArgs,
+ @Nullable final ExpiryPolicy expiryPlc,
+ final boolean retval,
+ final boolean lockOnly,
+ final CacheEntryPredicate[] filter,
+ final GridCacheVersion drVer,
+ final long drTtl,
+ long drExpireTime,
+ final GridCacheReturn ret,
+ @Nullable final Collection<KeyCacheObject> enlisted,
+ boolean skipStore,
+ boolean singleRmv,
+ boolean hasFilters,
+ final boolean needVal,
+ boolean needReadVer,
+ boolean keepBinary
+ ) throws IgniteCheckedException {
+ boolean loadMissed = false;
+
+ final boolean rmv = val == null && entryProcessor == null;
+
+ IgniteTxKey txKey = cacheCtx.txKey(cacheKey);
+
+ IgniteTxEntry txEntry = entry(txKey);
+
+ // First time access.
+ if (txEntry == null) {
+ while (true) {
+ GridCacheEntryEx entry = entryEx(cacheCtx, txKey, entryTopVer != null ? entryTopVer : topologyVersion());
+
+ try {
+ entry.unswap(false);
+
+ // Check if lock is being explicitly acquired by the same thread.
+ if (!implicit && cctx.kernalContext().config().isCacheSanityCheckEnabled() &&
+ entry.lockedByThread(threadId, xidVer)) {
+ throw new IgniteCheckedException("Cannot access key within transaction if lock is " +
+ "externally held [key=" + CU.value(cacheKey, cacheCtx, false) +
+ ", entry=" + entry +
+ ", xidVer=" + xidVer +
+ ", threadId=" + threadId +
+ ", locNodeId=" + cctx.localNodeId() + ']');
+ }
+
+ CacheObject old = null;
+ GridCacheVersion readVer = null;
+
+ if (optimistic() && !implicit()) {
+ try {
+ if (needReadVer) {
+ EntryGetResult res = primaryLocal(entry) ?
+ entry.innerGetVersioned(
+ null,
+ this,
+ /*swap*/false,
+ /*unmarshal*/retval || needVal,
+ /*metrics*/retval,
+ /*events*/retval,
+ CU.subjectId(this, cctx),
+ entryProcessor,
+ resolveTaskName(),
+ null,
+ keepBinary,
+ null) : null;
+
+ if (res != null) {
+ old = res.value();
+ readVer = res.version();
+ }
+ }
+ else {
+ old = entry.innerGet(
+ null,
+ this,
+ /*swap*/false,
+ /*read-through*/false,
+ /*metrics*/retval,
+ /*events*/retval,
+ /*temporary*/false,
+ CU.subjectId(this, cctx),
+ entryProcessor,
+ resolveTaskName(),
+ null,
+ keepBinary);
+ }
+ }
+ catch (ClusterTopologyCheckedException e) {
+ entry.context().evicts().touch(entry, topologyVersion());
+
+ throw e;
+ }
+ }
+ else
+ old = retval ? entry.rawGetOrUnmarshal(false) : entry.rawGet();
+
+ final GridCacheOperation op = lockOnly ? NOOP : rmv ? DELETE :
+ entryProcessor != null ? TRANSFORM : old != null ? UPDATE : CREATE;
+
+ if (old != null && hasFilters && !filter(entry.context(), cacheKey, old, filter)) {
+ ret.set(cacheCtx, old, false, keepBinary);
+
+ if (!readCommitted()) {
+ if (optimistic() && serializable()) {
+ txEntry = addEntry(op,
+ old,
+ entryProcessor,
+ invokeArgs,
+ entry,
+ expiryPlc,
+ filter,
+ true,
+ drTtl,
+ drExpireTime,
+ drVer,
+ skipStore,
+ keepBinary);
+ }
+ else {
+ txEntry = addEntry(READ,
+ old,
+ null,
+ null,
+ entry,
+ null,
+ CU.empty0(),
+ false,
+ -1L,
+ -1L,
+ null,
+ skipStore,
+ keepBinary);
+ }
+
+ txEntry.markValid();
+
+ if (needReadVer) {
+ assert readVer != null;
+
+ txEntry.entryReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
+ }
+ }
+
+ if (readCommitted())
+ cacheCtx.evicts().touch(entry, topologyVersion());
+
+ break; // While.
+ }
+
+ txEntry = addEntry(op,
+ cacheCtx.toCacheObject(val),
+ entryProcessor,
+ invokeArgs,
+ entry,
+ expiryPlc,
+ filter,
+ true,
+ drTtl,
+ drExpireTime,
+ drVer,
+ skipStore,
+ keepBinary);
+
+ if (!implicit() && readCommitted() && !cacheCtx.offheapTiered())
+ cacheCtx.evicts().touch(entry, topologyVersion());
+
+ if (enlisted != null)
+ enlisted.add(cacheKey);
+
+ if (!pessimistic() && !implicit()) {
+ txEntry.markValid();
+
+ if (old == null) {
+ if (needVal)
+ loadMissed = true;
+ else {
+ assert !implicit() || !transform : this;
+ assert txEntry.op() != TRANSFORM : txEntry;
+
+ if (retval)
+ ret.set(cacheCtx, null, true, keepBinary);
+ else
+ ret.success(true);
+ }
+ }
+ else {
+ if (needReadVer) {
+ assert readVer != null;
+
+ txEntry.entryReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
+ }
+
+ if (retval && !transform)
+ ret.set(cacheCtx, old, true, keepBinary);
+ else {
+ if (txEntry.op() == TRANSFORM) {
+ GridCacheVersion ver;
+
+ try {
+ ver = entry.version();
+ }
+ catch (GridCacheEntryRemovedException ex) {
+ assert optimistic() : txEntry;
+
+ if (log.isDebugEnabled())
+ log.debug("Failed to get entry version " +
+ "[err=" + ex.getMessage() + ']');
+
+ ver = null;
+ }
+
+ addInvokeResult(txEntry, old, ret, ver);
+ }
+ else
+ ret.success(true);
+ }
+ }
+ }
+ // Pessimistic.
+ else {
+ if (retval && !transform)
+ ret.set(cacheCtx, old, true, keepBinary);
+ else
+ ret.success(true);
+ }
+
+ break; // While.
+ }
+ catch (GridCacheEntryRemovedException ignore) {
+ if (log.isDebugEnabled())
+ log.debug("Got removed entry in transaction putAll0 method: " + entry);
+ }
+ }
+ }
+ else {
+ if (entryProcessor == null && txEntry.op() == TRANSFORM)
+ throw new IgniteCheckedException("Failed to enlist write value for key (cannot have update value in " +
+ "transaction after EntryProcessor is applied): " + CU.value(cacheKey, cacheCtx, false));
+
+ GridCacheEntryEx entry = txEntry.cached();
+
+ CacheObject v = txEntry.value();
+
+ boolean del = txEntry.op() == DELETE && rmv;
+
+ if (!del) {
+ if (hasFilters && !filter(entry.context(), cacheKey, v, filter)) {
+ ret.set(cacheCtx, v, false, keepBinary);
+
+ return loadMissed;
+ }
+
+ GridCacheOperation op = rmv ? DELETE : entryProcessor != null ? TRANSFORM :
+ v != null ? UPDATE : CREATE;
+
+ txEntry = addEntry(op,
+ cacheCtx.toCacheObject(val),
+ entryProcessor,
+ invokeArgs,
+ entry,
+ expiryPlc,
+ filter,
+ true,
+ drTtl,
+ drExpireTime,
+ drVer,
+ skipStore,
+ keepBinary);
+
+ if (enlisted != null)
+ enlisted.add(cacheKey);
+
+ if (txEntry.op() == TRANSFORM) {
+ GridCacheVersion ver;
+
+ try {
+ ver = entry.version();
+ }
+ catch (GridCacheEntryRemovedException e) {
+ assert optimistic() : txEntry;
+
+ if (log.isDebugEnabled())
+ log.debug("Failed to get entry version: [msg=" + e.getMessage() + ']');
+
+ ver = null;
+ }
+
+ addInvokeResult(txEntry, txEntry.value(), ret, ver);
+ }
+ }
+
+ if (!pessimistic()) {
+ txEntry.markValid();
+
+ if (retval && !transform)
+ ret.set(cacheCtx, v, true, keepBinary);
+ else
+ ret.success(true);
+ }
+ }
+
+ return loadMissed;
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param keys Keys to remove.
+ * @param drMap DR map.
+ * @param retval Flag indicating whether a value should be returned.
+ * @param filter Filter.
+ * @param singleRmv {@code True} for single key remove operation ({@link Cache#remove(Object)}.
+ * @return Future for asynchronous remove.
+ */
+ @SuppressWarnings("unchecked")
+ private <K, V> IgniteInternalFuture<GridCacheReturn> removeAllAsync0(
+ final GridCacheContext cacheCtx,
+ @Nullable AffinityTopologyVersion entryTopVer,
+ @Nullable final Collection<? extends K> keys,
+ @Nullable Map<KeyCacheObject, GridCacheVersion> drMap,
+ final boolean retval,
+ @Nullable final CacheEntryPredicate filter,
+ boolean singleRmv) {
+ try {
+ checkUpdatesAllowed(cacheCtx);
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture(e);
+ }
+
+ cacheCtx.checkSecurity(SecurityPermission.CACHE_REMOVE);
+
+ if (retval)
+ needReturnValue(true);
+
+ final Collection<?> keys0;
+
+ if (drMap != null) {
+ assert keys == null;
+
+ keys0 = drMap.keySet();
+ }
+ else
+ keys0 = keys;
+
+ CacheOperationContext opCtx = cacheCtx.operationContextPerCall();
+
+ final Byte dataCenterId;
+
+ if (opCtx != null && opCtx.hasDataCenterId()) {
+ assert drMap == null : drMap;
+
+ dataCenterId = opCtx.dataCenterId();
+ }
+ else
+ dataCenterId = null;
+
+ assert keys0 != null;
+
+ if (log.isDebugEnabled())
+ log.debug(S.toString("Called removeAllAsync(...)",
+ "tx", this, false,
+ "keys", keys0, true,
+ "implicit", implicit, false,
+ "retval", retval, false));
+
+ try {
+ checkValid();
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture<>(e);
+ }
+
+ final GridCacheReturn ret = new GridCacheReturn(localResult(), false);
+
+ if (F.isEmpty(keys0)) {
+ if (implicit()) {
+ try {
+ commit();
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture<>(e);
+ }
+ }
+
+ return new GridFinishedFuture<>(ret.success(true));
+ }
+
+ init();
+
+ final Collection<KeyCacheObject> enlisted = new ArrayList<>();
+
+ ExpiryPolicy plc;
+
+ final CacheEntryPredicate[] filters = CU.filterArray(filter);
+
+ if (!F.isEmpty(filters))
+ plc = opCtx != null ? opCtx.expiry() : null;
+ else
+ plc = null;
+
+ final boolean keepBinary = opCtx != null && opCtx.isKeepBinary();
+
+ final IgniteInternalFuture<Void> loadFut = enlistWrite(
+ cacheCtx,
+ entryTopVer,
+ keys0,
+ plc,
+ /*lookup map*/null,
+ /*invoke map*/null,
+ /*invoke arguments*/null,
+ retval,
+ /*lock only*/false,
+ filters,
+ ret,
+ enlisted,
+ null,
+ drMap,
+ opCtx != null && opCtx.skipStore(),
+ singleRmv,
+ keepBinary,
+ dataCenterId
+ );
+
+ if (log.isDebugEnabled())
+ log.debug("Remove keys: " + enlisted);
+
+ // 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()) {
+ assert loadFut == null || loadFut.isDone() : loadFut;
+
+ if (loadFut != null) {
+ try {
+ loadFut.get();
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture<>(e);
+ }
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Before acquiring transaction lock for remove on keys: " + enlisted);
+
+ long timeout = remainingTime();
+
+ if (timeout == -1)
+ return new GridFinishedFuture<>(timeoutException());
+
+ IgniteInternalFuture<Boolean> fut = cacheCtx.cache().txLockAsync(enlisted,
+ timeout,
+ this,
+ false,
+ retval,
+ isolation,
+ isInvalidate(),
+ -1L,
+ -1L);
+
+ PLC1<GridCacheReturn> plc1 = new PLC1<GridCacheReturn>(ret) {
+ @Override protected GridCacheReturn postLock(GridCacheReturn ret)
+ throws IgniteCheckedException
+ {
+ if (log.isDebugEnabled())
+ log.debug("Acquired transaction lock for remove on keys: " + enlisted);
+
+ postLockWrite(cacheCtx,
+ enlisted,
+ ret,
+ /*remove*/true,
+ retval,
+ /*read*/false,
+ -1L,
+ filters,
+ /*computeInvoke*/false);
+
+ return ret;
+ }
+ };
+
+ if (fut.isDone()) {
+ try {
+ return nonInterruptable(plc1.apply(fut.get(), null));
+ }
+ catch (GridClosureException e) {
+ return new GridFinishedFuture<>(e.unwrap());
+ }
+ catch (IgniteCheckedException e) {
+ try {
+ return nonInterruptable(plc1.apply(false, e));
+ }
+ catch (Exception e1) {
+ return new GridFinishedFuture<>(e1);
+ }
+ }
+ }
+ else
+ return nonInterruptable(new GridEmbeddedFuture<>(
+ fut,
+ plc1
+ ));
+ }
+ else {
+ if (implicit()) {
+ // Should never load missing values for implicit transaction as values will be returned
+ // with prepare response, if required.
+ assert loadFut.isDone();
+
+ return nonInterruptable(commitNearTxLocalAsync().chain(new CX1<IgniteInternalFuture<IgniteInternalTx>, GridCacheReturn>() {
+ @Override public GridCacheReturn applyx(IgniteInternalFuture<IgniteInternalTx> txFut)
+ throws IgniteCheckedException {
+ try {
+ txFut.get();
+
+ return new GridCacheReturn(cacheCtx, true, keepBinary,
+ implicitRes.value(), implicitRes.success());
+ }
+ catch (IgniteCheckedException | RuntimeException e) {
+ rollbackNearTxLocalAsync();
+
+ throw e;
+ }
+ }
+ }));
+ }
+ else {
+ return nonInterruptable(loadFut.chain(new CX1<IgniteInternalFuture<Void>, GridCacheReturn>() {
+ @Override public GridCacheReturn applyx(IgniteInternalFuture<Void> f)
+ throws IgniteCheckedException {
+ f.get();
+
+ return ret;
+ }
+ }));
+ }
+ }
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param keys Keys to get.
+ * @param deserializeBinary Deserialize binary flag.
+ * @param skipVals Skip values flag.
+ * @param keepCacheObjects Keep cache objects
+ * @param skipStore Skip store flag.
+ * @return Future for this get.
+ */
+ @SuppressWarnings("unchecked")
+ public <K, V> IgniteInternalFuture<Map<K, V>> getAllAsync(
+ final GridCacheContext cacheCtx,
+ @Nullable final AffinityTopologyVersion entryTopVer,
+ Collection<KeyCacheObject> keys,
+ final boolean deserializeBinary,
+ final boolean skipVals,
+ final boolean keepCacheObjects,
+ final boolean skipStore,
+ final boolean needVer) {
+ if (F.isEmpty(keys))
+ return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
+
+ init();
+
+ int keysCnt = keys.size();
+
+ boolean single = keysCnt == 1;
+
+ try {
+ checkValid();
+
+ final Map<K, V> retMap = new GridLeanMap<>(keysCnt);
+
+ final Map<KeyCacheObject, GridCacheVersion> missed = new GridLeanMap<>(pessimistic() ? keysCnt : 0);
+
+ CacheOperationContext opCtx = cacheCtx.operationContextPerCall();
+
+ ExpiryPolicy expiryPlc = opCtx != null ? opCtx.expiry() : null;
+
+ final Collection<KeyCacheObject> lockKeys = enlistRead(cacheCtx,
+ entryTopVer,
+ keys,
+ expiryPlc,
+ retMap,
+ missed,
+ keysCnt,
+ deserializeBinary,
+ skipVals,
+ keepCacheObjects,
+ skipStore,
+ needVer);
+
+ if (single && missed.isEmpty())
+ return new GridFinishedFuture<>(retMap);
+
+ // Handle locks.
+ if (pessimistic() && !readCommitted() && !skipVals) {
+ if (expiryPlc == null)
+ expiryPlc = cacheCtx.expiry();
+
+ long accessTtl = expiryPlc != null ? CU.toTtl(expiryPlc.getExpiryForAccess()) : CU.TTL_NOT_CHANGED;
+ long createTtl = expiryPlc != null ? CU.toTtl(expiryPlc.getExpiryForCreation()) : CU.TTL_NOT_CHANGED;
+
+ long timeout = remainingTime();
+
+ if (timeout == -1)
+ return new GridFinishedFuture<>(timeoutException());
+
+ IgniteInternalFuture<Boolean> fut = cacheCtx.cache().txLockAsync(lockKeys,
+ timeout,
+ this,
+ true,
+ true,
+ isolation,
+ isInvalidate(),
+ createTtl,
+ accessTtl);
+
+ final ExpiryPolicy expiryPlc0 = expiryPlc;
+
+ PLC2<Map<K, V>> plc2 = new PLC2<Map<K, V>>() {
+ @Override public IgniteInternalFuture<Map<K, V>> postLock() throws IgniteCheckedException {
+ if (log.isDebugEnabled())
+ log.debug("Acquired transaction lock for read on keys: " + lockKeys);
+
+ // Load keys only after the locks have been acquired.
+ for (KeyCacheObject cacheKey : lockKeys) {
+ K keyVal = (K)
+ (keepCacheObjects ? cacheKey :
+ cacheCtx.cacheObjectContext().unwrapBinaryIfNeeded(cacheKey, !deserializeBinary));
+
+ if (retMap.containsKey(keyVal))
+ // We already have a return value.
+ continue;
+
+ IgniteTxKey txKey = cacheCtx.txKey(cacheKey);
+
+ IgniteTxEntry txEntry = entry(txKey);
+
+ assert txEntry != null;
+
+ // Check if there is cached value.
+ while (true) {
+ GridCacheEntryEx cached = txEntry.cached();
+
+ CacheObject val = null;
+ GridCacheVersion readVer = null;
+ EntryGetResult getRes = null;
+
+ try {
+ Object transformClo =
+ (!F.isEmpty(txEntry.entryProcessors()) &&
+ cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ)) ?
+ F.first(txEntry.entryProcessors()) : null;
+
+ if (needVer) {
+ getRes = cached.innerGetVersioned(
+ null,
+ GridNearTxLocal.this,
+ /*swap*/cacheCtx.isSwapOrOffheapEnabled(),
+ /*unmarshal*/true,
+ /*update-metrics*/true,
+ /*event*/!skipVals,
+ CU.subjectId(GridNearTxLocal.this, cctx),
+ transformClo,
+ resolveTaskName(),
+ null,
+ txEntry.keepBinary(),
+ null);
+
+ if (getRes != null) {
+ val = getRes.value();
+ readVer = getRes.version();
+ }
+ }
+ else{
+ val = cached.innerGet(
+ null,
+ GridNearTxLocal.this,
+ cacheCtx.isSwapOrOffheapEnabled(),
+ /*read-through*/false,
+ /*metrics*/true,
+ /*events*/!skipVals,
+ /*temporary*/false,
+ CU.subjectId(GridNearTxLocal.this, cctx),
+ transformClo,
+ resolveTaskName(),
+ null,
+ txEntry.keepBinary());
+ }
+
+ // If value is in cache and passed the filter.
+ if (val != null) {
+ missed.remove(cacheKey);
+
+ txEntry.setAndMarkValid(val);
+
+ if (!F.isEmpty(txEntry.entryProcessors()))
+ val = txEntry.applyEntryProcessors(val);
+
+ cacheCtx.addResult(retMap,
+ cacheKey,
+ val,
+ skipVals,
+ keepCacheObjects,
+ deserializeBinary,
+ false,
+ getRes,
+ readVer,
+ 0,
+ 0,
+ needVer);
+
+ if (readVer != null)
+ txEntry.entryReadVersion(readVer);
+ }
+
+ // Even though we bring the value back from lock acquisition,
+ // we still need to recheck primary node for consistent values
+ // in case of concurrent transactional locks.
+
+ break; // While.
+ }
+ catch (GridCacheEntryRemovedException ignore) {
+ if (log.isDebugEnabled())
+ log.debug("Got removed exception in get postLock (will retry): " +
+ cached);
+
+ txEntry.cached(entryEx(cacheCtx, txKey, topologyVersion()));
+ }
+ }
+ }
+
+ if (!missed.isEmpty() && cacheCtx.isLocal()) {
+ AffinityTopologyVersion topVer = topologyVersionSnapshot();
+
+ if (topVer == null)
+ topVer = entryTopVer;
+
+ return checkMissed(cacheCtx,
+ topVer != null ? topVer : topologyVersion(),
+ retMap,
+ missed,
+ deserializeBinary,
+ skipVals,
+ keepCacheObjects,
+ skipStore,
+ needVer,
+ expiryPlc0);
+ }
+
+ return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
+ }
+ };
+
+ FinishClosure<Map<K, V>> finClos = new FinishClosure<Map<K, V>>() {
+ @Override Map<K, V> finish(Map<K, V> loaded) {
+ retMap.putAll(loaded);
+
+ return retMap;
+ }
+ };
+
+ if (fut.isDone()) {
+ try {
+ IgniteInternalFuture<Map<K, V>> fut1 = plc2.apply(fut.get(), null);
+
+ return fut1.isDone() ?
+ new GridFinishedFuture<>(finClos.apply(fut1.get(), null)) :
+ new GridEmbeddedFuture<>(finClos, fut1);
+ }
+ catch (GridClosureException e) {
+ return new GridFinishedFuture<>(e.unwrap());
+ }
+ catch (IgniteCheckedException e) {
+ try {
+ return plc2.apply(false, e);
+ }
+ catch (Exception e1) {
+ return new GridFinishedFuture<>(e1);
+ }
+ }
+ }
+ else {
+ return new GridEmbeddedFuture<>(
+ fut,
+ plc2,
+ finClos);
+ }
+ }
+ else {
+ assert optimistic() || readCommitted() || skipVals;
+
+ if (!missed.isEmpty()) {
+ if (!readCommitted())
+ for (Iterator<KeyCacheObject> it = missed.keySet().iterator(); it.hasNext(); ) {
+ KeyCacheObject cacheKey = it.next();
+
+ K keyVal =
+ (K)(keepCacheObjects ? cacheKey : cacheKey.value(cacheCtx.cacheObjectContext(), false));
+
+ if (retMap.containsKey(keyVal))
+ it.remove();
+ }
+
+ if (missed.isEmpty())
+ return new GridFinishedFuture<>(retMap);
+
+ AffinityTopologyVersion topVer = topologyVersionSnapshot();
+
+ if (topVer == null)
+ topVer = entryTopVer;
+
+ return checkMissed(cacheCtx,
+ topVer != null ? topVer : topologyVersion(),
+ retMap,
+ missed,
+ deserializeBinary,
+ skipVals,
+ keepCacheObjects,
+ skipStore,
+ needVer,
+ expiryPlc);
+ }
+
+ return new GridFinishedFuture<>(retMap);
+ }
+ }
+ catch (IgniteCheckedException e) {
+ setRollbackOnly();
+
+ return new GridFinishedFuture<>(e);
+ }
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param keys Key to enlist.
+ * @param expiryPlc Explicitly specified expiry policy for entry.
+ * @param map Return map.
+ * @param missed Map of missed keys.
+ * @param keysCnt Keys count (to avoid call to {@code Collection.size()}).
+ * @param deserializeBinary Deserialize binary flag.
+ * @param skipVals Skip values flag.
+ * @param keepCacheObjects Keep cache objects flag.
+ * @param skipStore Skip store flag.
+ * @throws IgniteCheckedException If failed.
+ * @return Enlisted keys.
+ */
+ @SuppressWarnings({"RedundantTypeArguments"})
+ private <K, V> Collection<KeyCacheObject> enlistRead(
+ final GridCacheContext cacheCtx,
+ @Nullable AffinityTopologyVersion entryTopVer,
+ Collection<KeyCacheObject> keys,
+ @Nullable ExpiryPolicy expiryPlc,
+ Map<K, V> map,
+ Map<KeyCacheObject, GridCacheVersion> missed,
+ int keysCnt,
+ boolean deserializeBinary,
+ boolean skipVals,
+ boolean keepCacheObjects,
+ boolean skipStore,
+ final boolean needVer
+ ) throws IgniteCheckedException {
+ assert !F.isEmpty(keys);
+ assert keysCnt == keys.size();
+
+ cacheCtx.checkSecurity(SecurityPermission.CACHE_READ);
+
+ boolean single = keysCnt == 1;
+
+ Collection<KeyCacheObject> lockKeys = null;
+
+ AffinityTopologyVersion topVer = entryTopVer != null ? entryTopVer : topologyVersion();
+
+ boolean needReadVer = (serializable() && optimistic()) || needVer;
+
+ // In this loop we cover only read-committed or optimistic transactions.
+ // Transactions that are pessimistic and not read-committed are covered
+ // outside of this loop.
+ for (KeyCacheObject key : keys) {
+ if ((pessimistic() || needReadVer) && !readCommitted() && !skipVals)
+ addActiveCache(cacheCtx);
+
+ IgniteTxKey txKey = cacheCtx.txKey(key);
+
+ // Check write map (always check writes first).
+ IgniteTxEntry txEntry = entry(txKey);
+
+ // Either non-read-committed or there was a previous write.
+ if (txEntry != null) {
+ CacheObject val = txEntry.value();
+
+ if (txEntry.hasValue()) {
+ if (!F.isEmpty(txEntry.entryProcessors()))
+ val = txEntry.applyEntryProcessors(val);
+
+ if (val != null) {
+ GridCacheVersion ver = null;
+
+ if (needVer) {
+ if (txEntry.op() != READ)
+ ver = IgniteTxEntry.GET_ENTRY_INVALID_VER_UPDATED;
+ else {
+ ver = txEntry.entryReadVersion();
+
+ if (ver == null && pessimistic()) {
+ while (true) {
+ try {
+ GridCacheEntryEx cached = txEntry.cached();
+
+ ver = cached.isNear() ?
+ ((GridNearCacheEntry)cached).dhtVersion() : cached.version();
+
+ break;
+ }
+ catch (GridCacheEntryRemovedException ignored) {
+ txEntry.cached(entryEx(cacheCtx, txEntry.txKey(), topVer));
+ }
+ }
+ }
+
+ if (ver == null) {
+ assert optimistic() && repeatableRead() : this;
+
+ ver = IgniteTxEntry.GET_ENTRY_INVALID_VER_AFTER_GET;
+ }
+ }
+
+ assert ver != null;
+ }
+
+ cacheCtx.addResult(map, key, val, skipVals, keepCacheObjects, deserializeBinary, false,
+ ver, 0, 0);
+ }
+ }
+ else {
+ assert txEntry.op() == TRANSFORM;
+
+ while (true) {
+ try {
+ GridCacheVersion readVer = null;
+ EntryGetResult getRes = null;
+
+ Object transformClo =
+ (txEntry.op() == TRANSFORM &&
+ cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ)) ?
+ F.first(txEntry.entryProcessors()) : null;
+
+ if (needVer) {
+ getRes = txEntry.cached().innerGetVersioned(
+ null,
+ this,
+ /*swap*/true,
+ /*unmarshal*/true,
+ /*update-metrics*/true,
+ /*event*/!skipVals,
+ CU.subjectId(this, cctx),
+ transformClo,
+ resolveTaskName(),
+ null,
+ txEntry.keepBinary(),
+ null);
+
+ if (getRes != null) {
+ val = getRes.value();
+ readVer = getRes.version();
+ }
+ }
+ else {
+ val = txEntry.cached().innerGet(
+ null,
+ this,
+ /*swap*/true,
+ /*read-through*/false,
+ /*metrics*/true,
+ /*event*/!skipVals,
+ /*temporary*/false,
+ CU.subjectId(this, cctx),
+ transformClo,
+ resolveTaskName(),
+ null,
+ txEntry.keepBinary());
+ }
+
+ if (val != null) {
+ if (!readCommitted() && !skipVals)
+ txEntry.readValue(val);
+
+ if (!F.isEmpty(txEntry.entryProcessors()))
+ val = txEntry.applyEntryProcessors(val);
+
+ cacheCtx.addResult(map,
+ key,
+ val,
+ skipVals,
+ keepCacheObjects,
+ deserializeBinary,
+ false,
+ getRes,
+ readVer,
+ 0,
+ 0,
+ needVer);
+ }
+ else
+ missed.put(key, txEntry.cached().version());
+
+ break;
+ }
+ catch (GridCacheEntryRemovedException ignored) {
+ txEntry.cached(entryEx(cacheCtx, txEntry.txKey(), topVer));
+ }
+ }
+ }
+ }
+ // First time access within transaction.
+ else {
+ if (lockKeys == null && !skipVals)
+ lockKeys = single ? Collections.singleton(key) : new ArrayList<KeyCacheObject>(keysCnt);
+
+ if (!single && !skipVals)
+ lockKeys.add(key);
+
+ while (true) {
+ GridCacheEntryEx entry = entryEx(cacheCtx, txKey, topVer);
+
+ try {
+ GridCacheVersion ver = entry.version();
+
+ CacheObject val = null;
+ GridCacheVersion readVer = null;
+ EntryGetResult getRes = null;
+
+ if (!pessimistic() || readCommitted() && !skipVals) {
+ IgniteCacheExpiryPolicy accessPlc =
+ optimistic() ? accessPolicy(cacheCtx, txKey, expiryPlc) : null;
+
+ if (needReadVer) {
+ getRes = primaryLocal(entry) ?
+ entry.innerGetVersioned(
+ null,
+ this,
+ /*swap*/true,
+ /*unmarshal*/true,
+ /*metrics*/true,
+ /*event*/true,
+ CU.subjectId(this, cctx),
+ null,
+ resolveTaskName(),
+ accessPlc,
+ !deserializeBinary,
+ null) : null;
+
+ if (getRes != null) {
+ val = getRes.value();
+ readVer = getRes.version();
+ }
+ }
+ else {
+ val = entry.innerGet(
+ null,
+ this,
+ /*swap*/true,
+ /*read-through*/false,
+ /*metrics*/true,
+ /*event*/true,
+ /*temporary*/false,
+ CU.subjectId(this, cctx),
+ null,
+ resolveTaskName(),
+ accessPlc,
+ !deserializeBinary);
+ }
+
+ if (val != null) {
+ cacheCtx.addResult(map,
+ key,
+ val,
+ skipVals,
+ keepCacheObjects,
+ deserializeBinary,
+ false,
+ getRes,
+ readVer,
+ 0,
+ 0,
+ needVer);
+ }
+ else
+ missed.put(key, ver);
+ }
+ else
+ // We must wait for the lock in pessimistic mode.
+ missed.put(key, ver);
+
+ if (!readCommitted() && !skipVals) {
+ txEntry = addEntry(READ,
+ val,
+ null,
+ null,
+ entry,
+ expiryPlc,
+ null,
+ true,
+ -1L,
+ -1L,
+ null,
+ skipStore,
+ !deserializeBinary);
+
+ // As optimization, mark as checked immediately
+ // for non-pessimistic if value is not null.
+ if (val != null && !pessimistic()) {
+ txEntry.markValid();
+
+ if (needReadVer) {
+ assert readVer != null;
+
+ txEntry.entryReadVersion(readVer);
+ }
+ }
+ }
+
+ break; // While.
+ }
+ catch (GridCacheEntryRemovedException ignored) {
+ if (log.isDebugEnabled())
+ log.debug("Got removed entry in transaction getAllAsync(..) (will retry): " + key);
+ }
+ finally {
+ if (entry != null && readCommitted()) {
+ if (cacheCtx.isNear()) {
+ if (cacheCtx.affinity().partitionBelongs(cacheCtx.localNode(), entry.partition(), topVer)) {
+ if (entry.markObsolete(xidVer))
+ cacheCtx.cache().removeEntry(entry);
+ }
+ }
+ else
+ entry.context().evicts().touch(entry, topVer);
+ }
+ }
+ }
+ }
+ }
+
+ return lockKeys != null ? lockKeys : Collections.<KeyCacheObject>emptyList();
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param keys Keys to load.
+ * @param filter Filter.
+ * @param ret Return value.
+ * @param needReadVer Read version flag.
+ * @param singleRmv {@code True} for single remove operation.
+ * @param hasFilters {@code True} if filters not empty.
+ * @param readThrough Read through flag.
+ * @param retval Return value flag.
+ * @param expiryPlc Expiry policy.
+ * @return Load future.
+ */
+ private IgniteInternalFuture<Void> loadMissing(
+ final GridCacheContext cacheCtx,
+ final AffinityTopologyVersion topVer,
+ final Set<KeyCacheObject> keys,
+ final CacheEntryPredicate[] filter,
+ final GridCacheReturn ret,
+ final boolean needReadVer,
+ final boolean singleRmv,
+ final boolean hasFilters,
+ final boolean readThrough,
+ final boolean retval,
+ final boolean keepBinary,
+ final ExpiryPolicy expiryPlc) {
+ GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c =
+ new GridInClosure3<KeyCacheObject, Object, GridCacheVersion>() {
+ @Override public void apply(KeyCacheObject key,
+ @Nullable Object val,
+ @Nullable GridCacheVersion loadVer) {
+ if (log.isDebugEnabled())
+ log.debug("Loaded value from remote node [key=" + key + ", val=" + val + ']');
+
+ IgniteTxEntry e = entry(new IgniteTxKey(key, cacheCtx.cacheId()));
+
+ assert e != null;
+
+ if (needReadVer) {
+ assert loadVer != null;
+
+ e.entryReadVersion(singleRmv && val != null ? SER_READ_NOT_EMPTY_VER : loadVer);
+ }
+
+ if (singleRmv) {
+ assert !hasFilters && !retval;
+ assert val == null || Boolean.TRUE.equals(val) : val;
+
+ ret.set(cacheCtx, null, val != null, keepBinary);
+ }
+ else {
+ CacheObject cacheVal = cacheCtx.toCacheObject(val);
+
+ if (e.op() == TRANSFORM) {
+ GridCacheVersion ver;
+
+ e.readValue(cacheVal);
+
+ try {
+ ver = e.cached().version();
+ }
+ catch (GridCacheEntryRemovedException ex) {
+ assert optimistic() : e;
+
+ if (log.isDebugEnabled())
+ log.debug("Failed to get entry version: [msg=" + ex.getMessage() + ']');
+
+ ver = null;
+ }
+
+ addInvokeResult(e, cacheVal, ret, ver);
+ }
+ else {
+ boolean success;
+
+ if (hasFilters) {
+ success = isAll(e.context(), key, cacheVal, filter);
+
+ if (!success)
+ e.value(cacheVal, false, false);
+ }
+ else
+ success = true;
+
+ ret.set(cacheCtx, cacheVal, success, keepBinary);
+ }
+ }
+ }
+ };
+
+ return loadMissing(
+ cacheCtx,
+ topVer,
+ readThrough,
+ /*async*/true,
+ keys,
+ /*skipVals*/singleRmv,
+ needReadVer,
+ keepBinary,
+ expiryPlc,
+ c);
+ }
+
+ /**
+ * @param cacheCtx Cache context.
+ * @param loadFut Missing keys load future.
+ * @param ret Future result.
+ * @param keepBinary Keep binary flag.
+ * @return Future.
+ */
+ private IgniteInternalFuture optimisticPutFuture(
+ final GridCacheContext cacheCtx,
+ IgniteInternalFuture<Void> loadFut,
+ final GridCacheReturn ret,
+ final boolean keepBinary
+ ) {
+ if (implicit()) {
+ // Should never load missing values for implicit transaction as values will be returned
+ // with prepare response, if required.
+ assert loadFut.isDone();
+
+ try {
+ loadFut.get();
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture<>(e);
+ }
+
+ return nonInterruptable(commitNearTxLocalAsync().chain(
+ new CX1<IgniteInternalFuture<IgniteInternalTx>, GridCacheReturn>() {
+ @Override public GridCacheReturn applyx(IgniteInternalFuture<IgniteInternalTx> txFut)
+ throws IgniteCheckedException {
+ try {
+ txFut.get();
+
+ Object res = implicitRes.value();
+
+ if (implicitRes.invokeResult()) {
+ assert res == null || res instanceof Map : implicitRes;
- /**
- * @return If backup check was requested.
- */
- public boolean needCheckBackup() {
- return needCheckBackup != null;
- }
+ res = cacheCtx.unwrapInvokeResult((Map)res, keepBinary);
+ }
- /**
- * @return {@code True} if transaction contains at least one near cache key mapped to the local node.
- */
- public boolean nearLocallyMapped() {
- return nearLocallyMapped;
- }
+ return new GridCacheReturn(cacheCtx, true, keepBinary, res, implicitRes.success());
+ }
+ catch (IgniteCheckedException | RuntimeException e) {
+ if (!(e instanceof NodeStoppingException))
+ rollbackNearTxLocalAsync();
- /**
- * @param nearLocallyMapped {@code True} if transaction contains near key mapped to the local
<TRUNCATED>