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 2016/07/27 06:56:12 UTC
[1/6] ignite git commit: IGNITE-3504 .NET: Fix IBinaryObjectBuilder
setter methods
Repository: ignite
Updated Branches:
refs/heads/ignite-3553 [created] 07f103018
IGNITE-3504 .NET: Fix IBinaryObjectBuilder setter methods
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6917ec40
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6917ec40
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6917ec40
Branch: refs/heads/ignite-3553
Commit: 6917ec403816416a6cbc7eb0a5a3696b692059e0
Parents: fd50502
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Jul 25 16:12:51 2016 +0300
Committer: agura <ag...@gridgain.com>
Committed: Mon Jul 25 17:35:37 2016 +0300
----------------------------------------------------------------------
.../Binary/BinaryBuilderSelfTest.cs | 325 +++++++++++++++----
.../Binary/IBinaryObjectBuilder.cs | 2 +-
.../Impl/Binary/BinaryObjectBuilder.cs | 16 +-
.../Impl/Binary/BinaryWriter.cs | 133 +++++---
4 files changed, 345 insertions(+), 131 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6917ec40/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
index 40ecc1e..80788a6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
@@ -595,7 +595,8 @@ namespace Apache.Ignite.Core.Tests.Binary
[Test]
public void TestPrimitiveFields()
{
- IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(Primitives))
+ // Generic SetField method.
+ var binObj = _grid.GetBinary().GetBuilder(typeof(Primitives))
.SetField<byte>("fByte", 1)
.SetField("fBool", true)
.SetField<short>("fShort", 2)
@@ -604,16 +605,73 @@ namespace Apache.Ignite.Core.Tests.Binary
.SetField<long>("fLong", 4)
.SetField<float>("fFloat", 5)
.SetField<double>("fDouble", 6)
+ .SetField("fDecimal", 7.7m)
.SetHashCode(100)
.Build();
+ CheckPrimitiveFields1(binObj);
+
+ // Specific setter methods.
+ binObj = _grid.GetBinary().GetBuilder(typeof(Primitives))
+ .SetByteField("fByte", 1)
+ .SetBooleanField("fBool", true)
+ .SetShortField("fShort", 2)
+ .SetCharField("fChar", 'a')
+ .SetIntField("fInt", 3)
+ .SetLongField("fLong", 4)
+ .SetFloatField("fFloat", 5)
+ .SetDoubleField("fDouble", 6)
+ .SetDecimalField("fDecimal", 7.7m)
+ .SetHashCode(100)
+ .Build();
+
+ CheckPrimitiveFields1(binObj);
+
+ // Overwrite with generic methods.
+ binObj = binObj.ToBuilder()
+ .SetField<byte>("fByte", 7)
+ .SetField("fBool", false)
+ .SetField<short>("fShort", 8)
+ .SetField("fChar", 'b')
+ .SetField("fInt", 9)
+ .SetField<long>("fLong", 10)
+ .SetField<float>("fFloat", 11)
+ .SetField<double>("fDouble", 12)
+ .SetField("fDecimal", 13.13m)
+ .SetHashCode(200)
+ .Build();
+
+ CheckPrimitiveFields2(binObj);
+
+ // Overwrite with specific methods.
+ binObj = binObj.ToBuilder()
+ .SetByteField("fByte", 7)
+ .SetBooleanField("fBool", false)
+ .SetShortField("fShort", 8)
+ .SetCharField("fChar", 'b')
+ .SetIntField("fInt", 9)
+ .SetLongField("fLong", 10)
+ .SetFloatField("fFloat", 11)
+ .SetDoubleField("fDouble", 12)
+ .SetDecimalField("fDecimal", 13.13m)
+ .SetHashCode(200)
+ .Build();
+
+ CheckPrimitiveFields2(binObj);
+ }
+
+ /// <summary>
+ /// Checks the primitive fields values.
+ /// </summary>
+ private static void CheckPrimitiveFields1(IBinaryObject binObj)
+ {
Assert.AreEqual(100, binObj.GetHashCode());
IBinaryType meta = binObj.GetBinaryType();
Assert.AreEqual(typeof(Primitives).Name, meta.TypeName);
- Assert.AreEqual(8, meta.Fields.Count);
+ Assert.AreEqual(9, meta.Fields.Count);
Assert.AreEqual(BinaryTypeNames.TypeNameByte, meta.GetFieldTypeName("fByte"));
Assert.AreEqual(BinaryTypeNames.TypeNameBool, meta.GetFieldTypeName("fBool"));
@@ -623,6 +681,7 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(BinaryTypeNames.TypeNameLong, meta.GetFieldTypeName("fLong"));
Assert.AreEqual(BinaryTypeNames.TypeNameFloat, meta.GetFieldTypeName("fFloat"));
Assert.AreEqual(BinaryTypeNames.TypeNameDouble, meta.GetFieldTypeName("fDouble"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameDecimal, meta.GetFieldTypeName("fDecimal"));
Assert.AreEqual(1, binObj.GetField<byte>("fByte"));
Assert.AreEqual(true, binObj.GetField<bool>("fBool"));
@@ -632,6 +691,7 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(4, binObj.GetField<long>("fLong"));
Assert.AreEqual(5, binObj.GetField<float>("fFloat"));
Assert.AreEqual(6, binObj.GetField<double>("fDouble"));
+ Assert.AreEqual(7.7m, binObj.GetField<decimal>("fDecimal"));
Primitives obj = binObj.Deserialize<Primitives>();
@@ -643,20 +703,14 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(4, obj.FLong);
Assert.AreEqual(5, obj.FFloat);
Assert.AreEqual(6, obj.FDouble);
+ Assert.AreEqual(7.7m, obj.FDecimal);
+ }
- // Overwrite.
- binObj = binObj.ToBuilder()
- .SetField<byte>("fByte", 7)
- .SetField("fBool", false)
- .SetField<short>("fShort", 8)
- .SetField("fChar", 'b')
- .SetField("fInt", 9)
- .SetField<long>("fLong", 10)
- .SetField<float>("fFloat", 11)
- .SetField<double>("fDouble", 12)
- .SetHashCode(200)
- .Build();
-
+ /// <summary>
+ /// Checks the primitive fields values.
+ /// </summary>
+ private static void CheckPrimitiveFields2(IBinaryObject binObj)
+ {
Assert.AreEqual(200, binObj.GetHashCode());
Assert.AreEqual(7, binObj.GetField<byte>("fByte"));
@@ -667,8 +721,9 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(10, binObj.GetField<long>("fLong"));
Assert.AreEqual(11, binObj.GetField<float>("fFloat"));
Assert.AreEqual(12, binObj.GetField<double>("fDouble"));
+ Assert.AreEqual(13.13m, binObj.GetField<decimal>("fDecimal"));
- obj = binObj.Deserialize<Primitives>();
+ var obj = binObj.Deserialize<Primitives>();
Assert.AreEqual(7, obj.FByte);
Assert.AreEqual(false, obj.FBool);
@@ -678,6 +733,7 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(10, obj.FLong);
Assert.AreEqual(11, obj.FFloat);
Assert.AreEqual(12, obj.FDouble);
+ Assert.AreEqual(13.13m, obj.FDecimal);
}
/// <summary>
@@ -686,7 +742,8 @@ namespace Apache.Ignite.Core.Tests.Binary
[Test]
public void TestPrimitiveArrayFields()
{
- IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(PrimitiveArrays))
+ // Generic SetField method.
+ var binObj = _grid.GetBinary().GetBuilder(typeof(PrimitiveArrays))
.SetField("fByte", new byte[] { 1 })
.SetField("fBool", new[] { true })
.SetField("fShort", new short[] { 2 })
@@ -695,16 +752,71 @@ namespace Apache.Ignite.Core.Tests.Binary
.SetField("fLong", new long[] { 4 })
.SetField("fFloat", new float[] { 5 })
.SetField("fDouble", new double[] { 6 })
+ .SetField("fDecimal", new decimal?[] { 7.7m })
.SetHashCode(100)
.Build();
+ CheckPrimitiveArrayFields1(binObj);
+
+ // Specific setters.
+ binObj = _grid.GetBinary().GetBuilder(typeof(PrimitiveArrays))
+ .SetByteArrayField("fByte", new byte[] {1})
+ .SetBooleanArrayField("fBool", new[] {true})
+ .SetShortArrayField("fShort", new short[] {2})
+ .SetCharArrayField("fChar", new[] {'a'})
+ .SetIntArrayField("fInt", new[] {3})
+ .SetLongArrayField("fLong", new long[] {4})
+ .SetFloatArrayField("fFloat", new float[] {5})
+ .SetDoubleArrayField("fDouble", new double[] {6})
+ .SetDecimalArrayField("fDecimal", new decimal?[] {7.7m})
+ .SetHashCode(100)
+ .Build();
+
+ // Overwrite with generic setter.
+ binObj = _grid.GetBinary().GetBuilder(binObj)
+ .SetField("fByte", new byte[] { 7 })
+ .SetField("fBool", new[] { false })
+ .SetField("fShort", new short[] { 8 })
+ .SetField("fChar", new[] { 'b' })
+ .SetField("fInt", new[] { 9 })
+ .SetField("fLong", new long[] { 10 })
+ .SetField("fFloat", new float[] { 11 })
+ .SetField("fDouble", new double[] { 12 })
+ .SetField("fDecimal", new decimal?[] { 13.13m })
+ .SetHashCode(200)
+ .Build();
+
+ CheckPrimitiveArrayFields2(binObj);
+
+ // Overwrite with specific setters.
+ binObj = _grid.GetBinary().GetBuilder(binObj)
+ .SetByteArrayField("fByte", new byte[] { 7 })
+ .SetBooleanArrayField("fBool", new[] { false })
+ .SetShortArrayField("fShort", new short[] { 8 })
+ .SetCharArrayField("fChar", new[] { 'b' })
+ .SetIntArrayField("fInt", new[] { 9 })
+ .SetLongArrayField("fLong", new long[] { 10 })
+ .SetFloatArrayField("fFloat", new float[] { 11 })
+ .SetDoubleArrayField("fDouble", new double[] { 12 })
+ .SetDecimalArrayField("fDecimal", new decimal?[] { 13.13m })
+ .SetHashCode(200)
+ .Build();
+
+ CheckPrimitiveArrayFields2(binObj);
+ }
+
+ /// <summary>
+ /// Checks the primitive array fields.
+ /// </summary>
+ private static void CheckPrimitiveArrayFields1(IBinaryObject binObj)
+ {
Assert.AreEqual(100, binObj.GetHashCode());
IBinaryType meta = binObj.GetBinaryType();
Assert.AreEqual(typeof(PrimitiveArrays).Name, meta.TypeName);
- Assert.AreEqual(8, meta.Fields.Count);
+ Assert.AreEqual(9, meta.Fields.Count);
Assert.AreEqual(BinaryTypeNames.TypeNameArrayByte, meta.GetFieldTypeName("fByte"));
Assert.AreEqual(BinaryTypeNames.TypeNameArrayBool, meta.GetFieldTypeName("fBool"));
@@ -714,6 +826,7 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(BinaryTypeNames.TypeNameArrayLong, meta.GetFieldTypeName("fLong"));
Assert.AreEqual(BinaryTypeNames.TypeNameArrayFloat, meta.GetFieldTypeName("fFloat"));
Assert.AreEqual(BinaryTypeNames.TypeNameArrayDouble, meta.GetFieldTypeName("fDouble"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayDecimal, meta.GetFieldTypeName("fDecimal"));
Assert.AreEqual(new byte[] { 1 }, binObj.GetField<byte[]>("fByte"));
Assert.AreEqual(new[] { true }, binObj.GetField<bool[]>("fBool"));
@@ -723,6 +836,7 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(new long[] { 4 }, binObj.GetField<long[]>("fLong"));
Assert.AreEqual(new float[] { 5 }, binObj.GetField<float[]>("fFloat"));
Assert.AreEqual(new double[] { 6 }, binObj.GetField<double[]>("fDouble"));
+ Assert.AreEqual(new decimal?[] { 7.7m }, binObj.GetField<decimal?[]>("fDecimal"));
PrimitiveArrays obj = binObj.Deserialize<PrimitiveArrays>();
@@ -734,20 +848,14 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(new long[] { 4 }, obj.FLong);
Assert.AreEqual(new float[] { 5 }, obj.FFloat);
Assert.AreEqual(new double[] { 6 }, obj.FDouble);
+ Assert.AreEqual(new decimal?[] { 7.7m }, obj.FDecimal);
+ }
- // Overwrite.
- binObj = _grid.GetBinary().GetBuilder(binObj)
- .SetField("fByte", new byte[] { 7 })
- .SetField("fBool", new[] { false })
- .SetField("fShort", new short[] { 8 })
- .SetField("fChar", new[] { 'b' })
- .SetField("fInt", new[] { 9 })
- .SetField("fLong", new long[] { 10 })
- .SetField("fFloat", new float[] { 11 })
- .SetField("fDouble", new double[] { 12 })
- .SetHashCode(200)
- .Build();
-
+ /// <summary>
+ /// Checks the primitive array fields.
+ /// </summary>
+ private static void CheckPrimitiveArrayFields2(IBinaryObject binObj)
+ {
Assert.AreEqual(200, binObj.GetHashCode());
Assert.AreEqual(new byte[] { 7 }, binObj.GetField<byte[]>("fByte"));
@@ -758,8 +866,9 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(new long[] { 10 }, binObj.GetField<long[]>("fLong"));
Assert.AreEqual(new float[] { 11 }, binObj.GetField<float[]>("fFloat"));
Assert.AreEqual(new double[] { 12 }, binObj.GetField<double[]>("fDouble"));
+ Assert.AreEqual(new decimal?[] { 13.13m }, binObj.GetField<decimal?[]>("fDecimal"));
- obj = binObj.Deserialize<PrimitiveArrays>();
+ var obj = binObj.Deserialize<PrimitiveArrays>();
Assert.AreEqual(new byte[] { 7 }, obj.FByte);
Assert.AreEqual(new[] { false }, obj.FBool);
@@ -769,6 +878,7 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(new long[] { 10 }, obj.FLong);
Assert.AreEqual(new float[] { 11 }, obj.FFloat);
Assert.AreEqual(new double[] { 12 }, obj.FDouble);
+ Assert.AreEqual(new decimal?[] { 13.13m }, obj.FDecimal);
}
/// <summary>
@@ -777,69 +887,141 @@ namespace Apache.Ignite.Core.Tests.Binary
[Test]
public void TestStringDateGuidEnum()
{
- DateTime? nDate = DateTime.Now;
+ DateTime? nDate = DateTime.Now.ToUniversalTime();
Guid? nGuid = Guid.NewGuid();
+ // Generic setters.
IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(StringDateGuidEnum))
.SetField("fStr", "str")
.SetField("fNDate", nDate)
- .SetGuidField("fNGuid", nGuid)
+ .SetTimestampField("fNTimestamp", nDate)
+ .SetField("fNGuid", nGuid)
.SetField("fEnum", TestEnum.One)
- .SetField("fStrArr", new[] { "str" })
+ .SetStringArrayField("fStrArr", new[] { "str" })
+ .SetArrayField("fDateArr", new[] { nDate })
+ .SetTimestampArrayField("fTimestampArr", new[] { nDate })
+ .SetGuidArrayField("fGuidArr", new[] { nGuid })
+ .SetEnumArrayField("fEnumArr", new[] { TestEnum.One })
+ .SetHashCode(100)
+ .Build();
+
+ CheckStringDateGuidEnum1(binObj, nDate, nGuid);
+
+ // Specific setters.
+ binObj = _grid.GetBinary().GetBuilder(typeof(StringDateGuidEnum))
+ .SetStringField("fStr", "str")
+ .SetField("fNDate", nDate)
+ .SetTimestampField("fNTimestamp", nDate)
+ .SetGuidField("fNGuid", nGuid)
+ .SetEnumField("fEnum", TestEnum.One)
+ .SetStringArrayField("fStrArr", new[] { "str" })
.SetArrayField("fDateArr", new[] { nDate })
+ .SetTimestampArrayField("fTimestampArr", new[] { nDate })
.SetGuidArrayField("fGuidArr", new[] { nGuid })
- .SetField("fEnumArr", new[] { TestEnum.One })
+ .SetEnumArrayField("fEnumArr", new[] { TestEnum.One })
.SetHashCode(100)
.Build();
+ CheckStringDateGuidEnum1(binObj, nDate, nGuid);
+
+ // Overwrite.
+ nDate = DateTime.Now.ToUniversalTime();
+ nGuid = Guid.NewGuid();
+
+ binObj = _grid.GetBinary().GetBuilder(typeof(StringDateGuidEnum))
+ .SetField("fStr", "str2")
+ .SetField("fNDate", nDate)
+ .SetTimestampField("fNTimestamp", nDate)
+ .SetField("fNGuid", nGuid)
+ .SetField("fEnum", TestEnum.Two)
+ .SetField("fStrArr", new[] { "str2" })
+ .SetArrayField("fDateArr", new[] { nDate })
+ .SetTimestampArrayField("fTimestampArr", new[] { nDate })
+ .SetField("fGuidArr", new[] { nGuid })
+ .SetField("fEnumArr", new[] { TestEnum.Two })
+ .SetHashCode(200)
+ .Build();
+
+ CheckStringDateGuidEnum2(binObj, nDate, nGuid);
+
+ // Overwrite with specific setters
+ binObj = _grid.GetBinary().GetBuilder(typeof(StringDateGuidEnum))
+ .SetStringField("fStr", "str2")
+ .SetField("fNDate", nDate)
+ .SetTimestampField("fNTimestamp", nDate)
+ .SetGuidField("fNGuid", nGuid)
+ .SetEnumField("fEnum", TestEnum.Two)
+ .SetStringArrayField("fStrArr", new[] { "str2" })
+ .SetArrayField("fDateArr", new[] { nDate })
+ .SetTimestampArrayField("fTimestampArr", new[] { nDate })
+ .SetGuidArrayField("fGuidArr", new[] { nGuid })
+ .SetEnumArrayField("fEnumArr", new[] { TestEnum.Two })
+ .SetHashCode(200)
+ .Build();
+
+ CheckStringDateGuidEnum2(binObj, nDate, nGuid);
+ }
+
+ /// <summary>
+ /// Checks the string date guid enum values.
+ /// </summary>
+ private void CheckStringDateGuidEnum1(IBinaryObject binObj, DateTime? nDate, Guid? nGuid)
+ {
Assert.AreEqual(100, binObj.GetHashCode());
IBinaryType meta = binObj.GetBinaryType();
Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName);
- Assert.AreEqual(8, meta.Fields.Count);
+ Assert.AreEqual(10, meta.Fields.Count);
Assert.AreEqual(BinaryTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("fNDate"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameTimestamp, meta.GetFieldTypeName("fNTimestamp"));
Assert.AreEqual(BinaryTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
Assert.AreEqual(BinaryTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
Assert.AreEqual(BinaryTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("fDateArr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayTimestamp, meta.GetFieldTypeName("fTimestampArr"));
Assert.AreEqual(BinaryTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
Assert.AreEqual(BinaryTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));
Assert.AreEqual("str", binObj.GetField<string>("fStr"));
Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNTimestamp"));
Assert.AreEqual(nGuid, binObj.GetField<Guid?>("fNGuid"));
Assert.AreEqual(TestEnum.One, binObj.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str" }, binObj.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, binObj.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, binObj.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] {"str"}, binObj.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] {nDate}, binObj.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] {nDate}, binObj.GetField<DateTime?[]>("fTimestampArr"));
+ Assert.AreEqual(new[] {nGuid}, binObj.GetField<Guid?[]>("fGuidArr"));
Assert.AreEqual(new[] {TestEnum.One}, binObj.GetField<TestEnum[]>("fEnumArr"));
StringDateGuidEnum obj = binObj.Deserialize<StringDateGuidEnum>();
Assert.AreEqual("str", obj.FStr);
Assert.AreEqual(nDate, obj.FnDate);
+ Assert.AreEqual(nDate, obj.FnTimestamp);
Assert.AreEqual(nGuid, obj.FnGuid);
Assert.AreEqual(TestEnum.One, obj.FEnum);
- Assert.AreEqual(new[] { "str" }, obj.FStrArr);
- Assert.AreEqual(new[] { nDate }, obj.FDateArr);
- Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
- Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
+ Assert.AreEqual(new[] {"str"}, obj.FStrArr);
+ Assert.AreEqual(new[] {nDate}, obj.FDateArr);
+ Assert.AreEqual(new[] {nGuid}, obj.FGuidArr);
+ Assert.AreEqual(new[] {TestEnum.One}, obj.FEnumArr);
// Check builder field caching.
var builder = _grid.GetBinary().GetBuilder(binObj);
Assert.AreEqual("str", builder.GetField<string>("fStr"));
Assert.AreEqual(nDate, builder.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nDate, builder.GetField<DateTime?>("fNTimestamp"));
Assert.AreEqual(nGuid, builder.GetField<Guid?>("fNGuid"));
Assert.AreEqual(TestEnum.One, builder.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str" }, builder.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, builder.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, builder.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] {"str"}, builder.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] {nDate}, builder.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] {nDate}, builder.GetField<DateTime?[]>("fTimestampArr"));
+ Assert.AreEqual(new[] {nGuid}, builder.GetField<Guid?[]>("fGuidArr"));
Assert.AreEqual(new[] {TestEnum.One}, builder.GetField<TestEnum[]>("fEnumArr"));
// Check reassemble.
@@ -847,55 +1029,51 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual("str", binObj.GetField<string>("fStr"));
Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNTimestamp"));
Assert.AreEqual(nGuid, binObj.GetField<Guid?>("fNGuid"));
Assert.AreEqual(TestEnum.One, binObj.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str" }, binObj.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, binObj.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, binObj.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] {"str"}, binObj.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] {nDate}, binObj.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] {nDate}, binObj.GetField<DateTime?[]>("fTimestampArr"));
+ Assert.AreEqual(new[] {nGuid}, binObj.GetField<Guid?[]>("fGuidArr"));
Assert.AreEqual(new[] {TestEnum.One}, binObj.GetField<TestEnum[]>("fEnumArr"));
obj = binObj.Deserialize<StringDateGuidEnum>();
Assert.AreEqual("str", obj.FStr);
Assert.AreEqual(nDate, obj.FnDate);
+ Assert.AreEqual(nDate, obj.FnTimestamp);
Assert.AreEqual(nGuid, obj.FnGuid);
Assert.AreEqual(TestEnum.One, obj.FEnum);
- Assert.AreEqual(new[] { "str" }, obj.FStrArr);
- Assert.AreEqual(new[] { nDate }, obj.FDateArr);
- Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
- Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
-
- // Overwrite.
- nDate = DateTime.Now.ToUniversalTime();
- nGuid = Guid.NewGuid();
-
- binObj = builder
- .SetField("fStr", "str2")
- .SetTimestampField("fNDate", nDate)
- .SetField("fNGuid", nGuid)
- .SetField("fEnum", TestEnum.Two)
- .SetField("fStrArr", new[] { "str2" })
- .SetArrayField("fDateArr", new[] { nDate })
- .SetField("fGuidArr", new[] { nGuid })
- .SetField("fEnumArr", new[] { TestEnum.Two })
- .SetHashCode(200)
- .Build();
+ Assert.AreEqual(new[] {"str"}, obj.FStrArr);
+ Assert.AreEqual(new[] {nDate}, obj.FDateArr);
+ Assert.AreEqual(new[] {nGuid}, obj.FGuidArr);
+ Assert.AreEqual(new[] {TestEnum.One}, obj.FEnumArr);
+ }
+ /// <summary>
+ /// Checks the string date guid enum values.
+ /// </summary>
+ private static void CheckStringDateGuidEnum2(IBinaryObject binObj, DateTime? nDate, Guid? nGuid)
+ {
Assert.AreEqual(200, binObj.GetHashCode());
Assert.AreEqual("str2", binObj.GetField<string>("fStr"));
Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNTimestamp"));
Assert.AreEqual(nGuid, binObj.GetField<Guid?>("fNGuid"));
Assert.AreEqual(TestEnum.Two, binObj.GetField<TestEnum>("fEnum"));
Assert.AreEqual(new[] { "str2" }, binObj.GetField<string[]>("fStrArr"));
Assert.AreEqual(new[] { nDate }, binObj.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nDate }, binObj.GetField<DateTime?[]>("fTimestampArr"));
Assert.AreEqual(new[] { nGuid }, binObj.GetField<Guid?[]>("fGuidArr"));
- Assert.AreEqual(new[] {TestEnum.Two}, binObj.GetField<TestEnum[]>("fEnumArr"));
+ Assert.AreEqual(new[] { TestEnum.Two }, binObj.GetField<TestEnum[]>("fEnumArr"));
- obj = binObj.Deserialize<StringDateGuidEnum>();
+ var obj = binObj.Deserialize<StringDateGuidEnum>();
Assert.AreEqual("str2", obj.FStr);
Assert.AreEqual(nDate, obj.FnDate);
+ Assert.AreEqual(nDate, obj.FnTimestamp);
Assert.AreEqual(nGuid, obj.FnGuid);
Assert.AreEqual(TestEnum.Two, obj.FEnum);
Assert.AreEqual(new[] { "str2" }, obj.FStrArr);
@@ -1524,6 +1702,7 @@ namespace Apache.Ignite.Core.Tests.Binary
public long FLong;
public float FFloat;
public double FDouble;
+ public decimal FDecimal;
}
/// <summary>
@@ -1539,6 +1718,7 @@ namespace Apache.Ignite.Core.Tests.Binary
public long[] FLong;
public float[] FFloat;
public double[] FDouble;
+ public decimal?[] FDecimal;
}
/// <summary>
@@ -1548,6 +1728,7 @@ namespace Apache.Ignite.Core.Tests.Binary
{
public string FStr;
public DateTime? FnDate;
+ public DateTime? FnTimestamp;
public Guid? FnGuid;
public TestEnum FEnum;
http://git-wip-us.apache.org/repos/asf/ignite/blob/6917ec40/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs
index abb9149..740706a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs
@@ -62,7 +62,7 @@ namespace Apache.Ignite.Core.Binary
/// <summary>
/// Set explicit hash code. If builder creating object from scratch,
/// then hash code initially set to 0. If builder is created from
- /// exising binary object, then hash code of that object is used
+ /// existing binary object, then hash code of that object is used
/// as initial value.
/// </summary>
/// <param name="hashCode">Hash code.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/6917ec40/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
index 083f557..646d563 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
@@ -151,7 +151,7 @@ namespace Apache.Ignite.Core.Impl.Binary
public IBinaryObjectBuilder SetBooleanField(string fieldName, bool val)
{
return SetField0(fieldName, new BinaryBuilderField(typeof (bool), val, BinaryUtils.TypeBool,
- (w, o) => w.WriteBoolean((bool) o)));
+ (w, o) => w.WriteBooleanField((bool) o)));
}
/** <inheritDoc /> */
@@ -165,7 +165,7 @@ namespace Apache.Ignite.Core.Impl.Binary
public IBinaryObjectBuilder SetByteField(string fieldName, byte val)
{
return SetField0(fieldName, new BinaryBuilderField(typeof (byte), val, BinaryUtils.TypeByte,
- (w, o) => w.WriteByte((byte) o)));
+ (w, o) => w.WriteByteField((byte) o)));
}
/** <inheritDoc /> */
@@ -179,7 +179,7 @@ namespace Apache.Ignite.Core.Impl.Binary
public IBinaryObjectBuilder SetCharField(string fieldName, char val)
{
return SetField0(fieldName, new BinaryBuilderField(typeof (char), val, BinaryUtils.TypeChar,
- (w, o) => w.WriteChar((char) o)));
+ (w, o) => w.WriteCharField((char) o)));
}
/** <inheritDoc /> */
@@ -221,7 +221,7 @@ namespace Apache.Ignite.Core.Impl.Binary
public IBinaryObjectBuilder SetDoubleField(string fieldName, double val)
{
return SetField0(fieldName, new BinaryBuilderField(typeof (double), val, BinaryUtils.TypeDouble,
- (w, o) => w.WriteDouble((double) o)));
+ (w, o) => w.WriteDoubleField((double) o)));
}
/** <inheritDoc /> */
@@ -249,7 +249,7 @@ namespace Apache.Ignite.Core.Impl.Binary
public IBinaryObjectBuilder SetFloatField(string fieldName, float val)
{
return SetField0(fieldName, new BinaryBuilderField(typeof (float), val, BinaryUtils.TypeFloat,
- (w, o) => w.WriteFloat((float) o)));
+ (w, o) => w.WriteFloatField((float) o)));
}
/** <inheritDoc /> */
@@ -277,7 +277,7 @@ namespace Apache.Ignite.Core.Impl.Binary
public IBinaryObjectBuilder SetIntField(string fieldName, int val)
{
return SetField0(fieldName, new BinaryBuilderField(typeof (int), val, BinaryUtils.TypeInt,
- (w, o) => w.WriteInt((int) o)));
+ (w, o) => w.WriteIntField((int) o)));
}
/** <inheritDoc /> */
@@ -291,7 +291,7 @@ namespace Apache.Ignite.Core.Impl.Binary
public IBinaryObjectBuilder SetLongField(string fieldName, long val)
{
return SetField0(fieldName, new BinaryBuilderField(typeof (long), val, BinaryUtils.TypeLong,
- (w, o) => w.WriteLong((long) o)));
+ (w, o) => w.WriteLongField((long) o)));
}
/** <inheritDoc /> */
@@ -305,7 +305,7 @@ namespace Apache.Ignite.Core.Impl.Binary
public IBinaryObjectBuilder SetShortField(string fieldName, short val)
{
return SetField0(fieldName, new BinaryBuilderField(typeof (short), val, BinaryUtils.TypeShort,
- (w, o) => w.WriteShort((short) o)));
+ (w, o) => w.WriteShortField((short) o)));
}
/** <inheritDoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/6917ec40/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
index 1ac98c4..a0b50ac 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
@@ -26,6 +26,7 @@ namespace Apache.Ignite.Core.Impl.Binary
using Apache.Ignite.Core.Impl.Binary.IO;
using Apache.Ignite.Core.Impl.Binary.Metadata;
using Apache.Ignite.Core.Impl.Binary.Structure;
+ using Apache.Ignite.Core.Impl.Common;
/// <summary>
/// Binary writer implementation.
@@ -87,11 +88,19 @@ namespace Apache.Ignite.Core.Impl.Binary
public void WriteBoolean(string fieldName, bool val)
{
WriteFieldId(fieldName, BinaryUtils.TypeBool);
+ WriteBooleanField(val);
+ }
+ /// <summary>
+ /// Writes the boolean field.
+ /// </summary>
+ /// <param name="val">if set to <c>true</c> [value].</param>
+ internal void WriteBooleanField(bool val)
+ {
_stream.WriteByte(BinaryUtils.TypeBool);
_stream.WriteBool(val);
}
-
+
/// <summary>
/// Write boolean value.
/// </summary>
@@ -142,7 +151,15 @@ namespace Apache.Ignite.Core.Impl.Binary
public void WriteByte(string fieldName, byte val)
{
WriteFieldId(fieldName, BinaryUtils.TypeBool);
+ WriteByteField(val);
+ }
+ /// <summary>
+ /// Write byte field value.
+ /// </summary>
+ /// <param name="val">Byte value.</param>
+ internal void WriteByteField(byte val)
+ {
_stream.WriteByte(BinaryUtils.TypeByte);
_stream.WriteByte(val);
}
@@ -197,7 +214,15 @@ namespace Apache.Ignite.Core.Impl.Binary
public void WriteShort(string fieldName, short val)
{
WriteFieldId(fieldName, BinaryUtils.TypeShort);
+ WriteShortField(val);
+ }
+ /// <summary>
+ /// Write short field value.
+ /// </summary>
+ /// <param name="val">Short value.</param>
+ internal void WriteShortField(short val)
+ {
_stream.WriteByte(BinaryUtils.TypeShort);
_stream.WriteShort(val);
}
@@ -252,7 +277,15 @@ namespace Apache.Ignite.Core.Impl.Binary
public void WriteChar(string fieldName, char val)
{
WriteFieldId(fieldName, BinaryUtils.TypeChar);
+ WriteCharField(val);
+ }
+ /// <summary>
+ /// Write char field value.
+ /// </summary>
+ /// <param name="val">Char value.</param>
+ internal void WriteCharField(char val)
+ {
_stream.WriteByte(BinaryUtils.TypeChar);
_stream.WriteChar(val);
}
@@ -307,7 +340,15 @@ namespace Apache.Ignite.Core.Impl.Binary
public void WriteInt(string fieldName, int val)
{
WriteFieldId(fieldName, BinaryUtils.TypeInt);
+ WriteIntField(val);
+ }
+ /// <summary>
+ /// Writes the int field.
+ /// </summary>
+ /// <param name="val">The value.</param>
+ internal void WriteIntField(int val)
+ {
_stream.WriteByte(BinaryUtils.TypeInt);
_stream.WriteInt(val);
}
@@ -362,7 +403,15 @@ namespace Apache.Ignite.Core.Impl.Binary
public void WriteLong(string fieldName, long val)
{
WriteFieldId(fieldName, BinaryUtils.TypeLong);
+ WriteLongField(val);
+ }
+ /// <summary>
+ /// Writes the long field.
+ /// </summary>
+ /// <param name="val">The value.</param>
+ internal void WriteLongField(long val)
+ {
_stream.WriteByte(BinaryUtils.TypeLong);
_stream.WriteLong(val);
}
@@ -417,7 +466,15 @@ namespace Apache.Ignite.Core.Impl.Binary
public void WriteFloat(string fieldName, float val)
{
WriteFieldId(fieldName, BinaryUtils.TypeFloat);
+ WriteFloatField(val);
+ }
+ /// <summary>
+ /// Writes the float field.
+ /// </summary>
+ /// <param name="val">The value.</param>
+ internal void WriteFloatField(float val)
+ {
_stream.WriteByte(BinaryUtils.TypeFloat);
_stream.WriteFloat(val);
}
@@ -472,7 +529,15 @@ namespace Apache.Ignite.Core.Impl.Binary
public void WriteDouble(string fieldName, double val)
{
WriteFieldId(fieldName, BinaryUtils.TypeDouble);
+ WriteDoubleField(val);
+ }
+ /// <summary>
+ /// Writes the double field.
+ /// </summary>
+ /// <param name="val">The value.</param>
+ internal void WriteDoubleField(double val)
+ {
_stream.WriteByte(BinaryUtils.TypeDouble);
_stream.WriteDouble(val);
}
@@ -1215,72 +1280,40 @@ namespace Apache.Ignite.Core.Impl.Binary
// Types check sequence is designed to minimize comparisons for the most frequent types.
if (type == typeof(int))
- {
- _stream.WriteByte(BinaryUtils.TypeInt);
- _stream.WriteInt((int)(object)val);
- }
+ WriteIntField(TypeCaster<int>.Cast(val));
else if (type == typeof(long))
- {
- _stream.WriteByte(BinaryUtils.TypeLong);
- _stream.WriteLong((long)(object)val);
- }
+ WriteLongField(TypeCaster<long>.Cast(val));
else if (type == typeof(bool))
- {
- _stream.WriteByte(BinaryUtils.TypeBool);
- _stream.WriteBool((bool)(object)val);
- }
+ WriteBooleanField(TypeCaster<bool>.Cast(val));
else if (type == typeof(byte))
- {
- _stream.WriteByte(BinaryUtils.TypeByte);
- _stream.WriteByte((byte)(object)val);
- }
+ WriteByteField(TypeCaster<byte>.Cast(val));
else if (type == typeof(short))
- {
- _stream.WriteByte(BinaryUtils.TypeShort);
- _stream.WriteShort((short)(object)val);
- }
- else if (type == typeof (char))
- {
- _stream.WriteByte(BinaryUtils.TypeChar);
- _stream.WriteChar((char)(object)val);
- }
+ WriteShortField(TypeCaster<short>.Cast(val));
+ else if (type == typeof(char))
+ WriteCharField(TypeCaster<char>.Cast(val));
else if (type == typeof(float))
- {
- _stream.WriteByte(BinaryUtils.TypeFloat);
- _stream.WriteFloat((float)(object)val);
- }
+ WriteFloatField(TypeCaster<float>.Cast(val));
else if (type == typeof(double))
- {
- _stream.WriteByte(BinaryUtils.TypeDouble);
- _stream.WriteDouble((double)(object)val);
- }
+ WriteDoubleField(TypeCaster<double>.Cast(val));
else if (type == typeof(sbyte))
{
- sbyte val0 = (sbyte)(object)val;
-
- _stream.WriteByte(BinaryUtils.TypeByte);
- _stream.WriteByte(*(byte*)&val0);
+ var val0 = TypeCaster<sbyte>.Cast(val);
+ WriteByteField(*(byte*)&val0);
}
else if (type == typeof(ushort))
{
- ushort val0 = (ushort)(object)val;
-
- _stream.WriteByte(BinaryUtils.TypeShort);
- _stream.WriteShort(*(short*)&val0);
+ var val0 = TypeCaster<ushort>.Cast(val);
+ WriteShortField(*(short*) &val0);
}
else if (type == typeof(uint))
{
- uint val0 = (uint)(object)val;
-
- _stream.WriteByte(BinaryUtils.TypeInt);
- _stream.WriteInt(*(int*)&val0);
+ var val0 = TypeCaster<uint>.Cast(val);
+ WriteIntField(*(int*)&val0);
}
else if (type == typeof(ulong))
{
- ulong val0 = (ulong)(object)val;
-
- _stream.WriteByte(BinaryUtils.TypeLong);
- _stream.WriteLong(*(long*)&val0);
+ var val0 = TypeCaster<ulong>.Cast(val);
+ WriteLongField(*(long*)&val0);
}
else
throw new BinaryObjectException("Unsupported object type [type=" + type.FullName + ", object=" + val + ']');
[2/6] ignite git commit: WIP. Implemented message write logic.
Posted by vo...@apache.org.
WIP. Implemented message write logic.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/72b4eb58
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/72b4eb58
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/72b4eb58
Branch: refs/heads/ignite-3553
Commit: 72b4eb581541163ed4b98ac97e5e26878f52ae89
Parents: 6917ec4
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Jul 26 11:05:58 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Jul 26 11:05:58 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/GridTopic.java | 5 +-
.../communication/GridIoMessageFactory.java | 12 ++
.../internal/processors/igfs/IgfsManager.java | 8 +-
.../igfs/client/IgfsClientAbstractCallable.java | 51 +++++++
.../igfs/client/IgfsClientAffinityCallable.java | 22 +++
.../igfs/client/IgfsClientClosureManager.java | 94 ++++++++++++
.../igfs/client/IgfsClientClosureRequest.java | 144 +++++++++++++++++++
.../igfs/client/IgfsClientClosureResponse.java | 32 +++++
.../igfs/client/IgfsClientDeleteCallable.java | 13 ++
.../igfs/client/IgfsClientMkdirsCallable.java | 14 ++
.../igfs/client/IgfsClientRenameCallable.java | 14 ++
.../igfs/client/IgfsClientSetTimesCallable.java | 19 +++
.../igfs/client/IgfsClientSizeCallable.java | 1 -
.../igfs/client/IgfsClientUpdateCallable.java | 14 ++
14 files changed, 437 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/GridTopic.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridTopic.java b/modules/core/src/main/java/org/apache/ignite/internal/GridTopic.java
index 248f75b..e5d47c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridTopic.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTopic.java
@@ -94,7 +94,10 @@ public enum GridTopic {
TOPIC_QUERY,
/** */
- TOPIC_TX;
+ TOPIC_TX,
+
+ /** Topic to handle IGFS closures. */
+ TOPIC_IGFS_CLO;
/** Enum values. */
private static final GridTopic[] VALS = values();
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
index 5f60215..b0f75dc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
@@ -120,6 +120,8 @@ import org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange;
import org.apache.ignite.internal.processors.igfs.IgfsFragmentizerRequest;
import org.apache.ignite.internal.processors.igfs.IgfsFragmentizerResponse;
import org.apache.ignite.internal.processors.igfs.IgfsSyncMessage;
+import org.apache.ignite.internal.processors.igfs.client.IgfsClientClosureRequest;
+import org.apache.ignite.internal.processors.igfs.client.IgfsClientClosureResponse;
import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest;
import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryFailResponse;
import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest;
@@ -160,6 +162,16 @@ public class GridIoMessageFactory implements MessageFactory {
Message msg = null;
switch (type) {
+ case -28:
+ msg = new IgfsClientClosureResponse();
+
+ break;
+
+ case -27:
+ msg = new IgfsClientClosureRequest();
+
+ break;
+
case -26:
msg = new TxLockList();
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsManager.java
index 1217d0b..cdd277b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsManager.java
@@ -129,27 +129,27 @@ public abstract class IgfsManager {
* @return Start info.
*/
protected String startInfo() {
- return "Cache manager started: " + getClass().getSimpleName();
+ return "IGFS manager started: " + getClass().getSimpleName();
}
/**
* @return Stop info.
*/
protected String stopInfo() {
- return "Cache manager stopped: " + getClass().getSimpleName();
+ return "IGFS manager stopped: " + getClass().getSimpleName();
}
/**
* @return Start info.
*/
protected String kernalStartInfo() {
- return "Cache manager received onKernalStart() callback: " + getClass().getSimpleName();
+ return "IGFS manager received onKernalStart() callback: " + getClass().getSimpleName();
}
/**
* @return Stop info.
*/
protected String kernalStopInfo() {
- return "Cache manager received onKernalStop() callback: " + getClass().getSimpleName();
+ return "IGFS manager received onKernalStop() callback: " + getClass().getSimpleName();
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
index d9c3456..85d4aea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
@@ -29,6 +29,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.processors.igfs.IgfsEx;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.jetbrains.annotations.Nullable;
@@ -39,6 +40,9 @@ public abstract class IgfsClientAbstractCallable<T> implements IgniteCallable<T>
/** */
private static final long serialVersionUID = 0L;
+ /** Base fields count. */
+ private static final byte BASE_FIELDS_CNT = 2;
+
/** IGFS name. */
protected String igfsName;
@@ -122,4 +126,51 @@ public abstract class IgfsClientAbstractCallable<T> implements IgniteCallable<T>
protected void readBinary0(BinaryRawReader rawReader) {
// No-op.
}
+
+ /**
+ * @return Fields count.
+ */
+ public final byte fieldsCount() {
+ return (byte)(BASE_FIELDS_CNT + fieldsCount0());
+ }
+
+ /**
+ * @return Additional fields count of concrete class.
+ */
+ protected byte fieldsCount0() {
+ return 0;
+ }
+
+ /**
+ * Write callable to writer.
+ *
+ * @param writer Writer.
+ * @param fieldId Field ID.
+ * @return Result.
+ */
+ public final boolean writeTo(MessageWriter writer, int fieldId) {
+ switch (fieldId) {
+ case 0:
+ return writer.writeString("igfsName", igfsName);
+
+ case 1:
+ return writer.writeString("path", path.toString());
+
+ default:
+ return writeTo0(writer, fieldId - BASE_FIELDS_CNT);
+ }
+ }
+
+ /**
+ * Write callable to writer (for child classes).
+ *
+ * @param writer Writer.
+ * @param fieldId Field ID.
+ * @return Result.
+ */
+ protected boolean writeTo0(MessageWriter writer, int fieldId) {
+ assert false : "Should not be called.";
+
+ return true;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
index 1668f36..3a63b77 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
@@ -24,6 +24,7 @@ import org.apache.ignite.igfs.IgfsBlockLocation;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
@@ -88,6 +89,27 @@ public class IgfsClientAffinityCallable extends IgfsClientAbstractCallable<Colle
}
/** {@inheritDoc} */
+ @Override protected byte fieldsCount0() {
+ return 3;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean writeTo0(MessageWriter writer, int fieldId) {
+ switch (fieldId) {
+ case 0:
+ return writer.writeLong("start", start);
+
+ case 1:
+ return writer.writeLong("len", len);
+
+ default:
+ assert fieldId == 2;
+
+ return writer.writeLong("maxLen", maxLen);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientAffinityCallable.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
new file mode 100644
index 0000000..7230cf2
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
@@ -0,0 +1,94 @@
+/*
+ * 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.igfs.client;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.FileSystemConfiguration;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
+import org.apache.ignite.internal.processors.igfs.IgfsManager;
+import org.apache.ignite.internal.util.GridStripedSpinBusyLock;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.marshaller.Marshaller;
+
+import java.util.concurrent.ConcurrentLinkedDeque;
+
+/**
+ * Manager to handle IGFS client closures.
+ */
+public class IgfsClientClosureManager extends IgfsManager {
+ /** Busy lock. */
+ private final GridStripedSpinBusyLock busyLock = new GridStripedSpinBusyLock();
+
+ /** Pending closures received when manager is not started yet. */
+ private final ConcurrentLinkedDeque startupClos = new ConcurrentLinkedDeque();
+
+ /** Kernal context. */
+ private GridKernalContext ctx;
+
+ /** IGFS configuration. */
+ private FileSystemConfiguration igfsCfg;
+
+ /** Marshaller. */
+ private Marshaller marsh;
+
+ /** {@inheritDoc} */
+ @Override protected void start0() throws IgniteCheckedException {
+ ctx = igfsCtx.kernalContext();
+
+ igfsCfg = igfsCtx.configuration();
+
+ marsh = ctx.config().getMarshaller();
+
+ ctx.discovery().setCustomEventListener();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void onKernalStart0() throws IgniteCheckedException {
+ // TODO
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void onKernalStop0(boolean cancel) {
+ // TODO
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void stop0(boolean cancel) {
+ // TODO
+ }
+
+ /**
+ * Execute callable.
+ *
+ * @param clo Closure.
+ * @return Result.
+ */
+ public <T> T execute(IgfsClientAbstractCallable<T> clo) {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsClientClosureManager.class, this);
+ }
+
+ private class DiscoveryListener implements GridLocalEventListener {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureRequest.java
new file mode 100644
index 0000000..a0bc3f4
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureRequest.java
@@ -0,0 +1,144 @@
+/*
+ * 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.igfs.client;
+
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
+
+import java.nio.ByteBuffer;
+import java.util.UUID;
+
+/**
+ * IGFS client closure execute request.
+ */
+public class IgfsClientClosureRequest implements Message {
+ /** Base fields (all except of target) count. */
+ private static final byte BASE_FIELDS_CNT = 2;
+
+ /** Originating node ID. */
+ private UUID nodeId;
+
+ /** Message ID. */
+ private long msgId;
+
+ /** Target callable. */
+ private IgfsClientAbstractCallable target;
+
+ /**
+ * Default constructor.
+ */
+ public IgfsClientClosureRequest() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param nodeId Originating node ID.
+ * @param msgId Message ID.
+ * @param target Target callable.
+ */
+ public IgfsClientClosureRequest(UUID nodeId, long msgId, IgfsClientAbstractCallable target) {
+ assert nodeId != null;
+ assert target != null;
+
+ this.nodeId = nodeId;
+ this.msgId = msgId;
+ this.target = target;
+ }
+
+ /**
+ * @return Node ID.
+ */
+ public UUID nodeId() {
+ return nodeId;
+ }
+
+ /**
+ * @return Message ID.
+ */
+ public long messageId() {
+ return msgId;
+ }
+
+ /**
+ * @return Target callable.
+ */
+ public IgfsClientAbstractCallable target() {
+ return target;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte directType() {
+ return -27;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte fieldsCount() {
+ return (byte)(BASE_FIELDS_CNT + target.fieldsCount());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onAckReceived() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
+ byte fieldsCount = fieldsCount();
+
+ writer.setBuffer(buf);
+
+ if (!writer.isHeaderWritten()) {
+ if (!writer.writeHeader(directType(), fieldsCount))
+ return false;
+
+ writer.onHeaderWritten();
+ }
+
+ switch (writer.state()) {
+ case 0:
+ if (!writer.writeUuid("nodeId", nodeId))
+ return false;
+
+ writer.incrementState();
+
+ case 1:
+ if (!writer.writeLong("msgId", msgId))
+ return false;
+
+ writer.incrementState();
+
+ default:
+ while (writer.state() < fieldsCount) {
+ if (!target.writeTo(writer, writer.state() - BASE_FIELDS_CNT))
+ return false;
+
+ writer.incrementState();
+ }
+ }
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java
new file mode 100644
index 0000000..3a7694a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java
@@ -0,0 +1,32 @@
+/*
+ * 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.igfs.client;
+
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/**
+ * CIGFS client closure execute response.
+ */
+public class IgfsClientClosureResponse implements Message {
+ /**
+ * Default constructor.
+ */
+ public IgfsClientClosureResponse() {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
index c1b8be8..9f12ea9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
@@ -23,6 +23,7 @@ import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
/**
@@ -71,6 +72,18 @@ public class IgfsClientDeleteCallable extends IgfsClientAbstractCallable<Boolean
}
/** {@inheritDoc} */
+ @Override protected byte fieldsCount0() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean writeTo0(MessageWriter writer, int fieldId) {
+ assert fieldId == 0;
+
+ return writer.writeBoolean("recursive", recursive);
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientDeleteCallable.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
index 944da6f..e8ca351 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
@@ -24,6 +24,8 @@ import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
@@ -76,6 +78,18 @@ public class IgfsClientMkdirsCallable extends IgfsClientAbstractCallable<Void> {
}
/** {@inheritDoc} */
+ @Override protected byte fieldsCount0() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean writeTo0(MessageWriter writer, int fieldId) {
+ assert fieldId == 0;
+
+ return writer.writeMap("props", props, MessageCollectionItemType.STRING, MessageCollectionItemType.STRING);
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientMkdirsCallable.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
index 55afb83..e9cc947 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
@@ -24,6 +24,8 @@ import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
/**
@@ -74,6 +76,18 @@ public class IgfsClientRenameCallable extends IgfsClientAbstractCallable<Void> {
}
/** {@inheritDoc} */
+ @Override protected byte fieldsCount0() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean writeTo0(MessageWriter writer, int fieldId) {
+ assert fieldId == 0;
+
+ return writer.writeString("destPath", destPath.toString());
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientRenameCallable.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
index 277effc..f1beb54 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
@@ -23,6 +23,7 @@ import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
/**
@@ -81,6 +82,24 @@ public class IgfsClientSetTimesCallable extends IgfsClientAbstractCallable<Void>
}
/** {@inheritDoc} */
+ @Override protected byte fieldsCount0() {
+ return 2;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean writeTo0(MessageWriter writer, int fieldId) {
+ switch (fieldId) {
+ case 0:
+ return writer.writeLong("accessTime", accessTime);
+
+ default:
+ assert fieldId == 1;
+
+ return writer.writeLong("modificationTime", modificationTime);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientSetTimesCallable.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
index 474a940..928d65d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
@@ -17,7 +17,6 @@
package org.apache.ignite.internal.processors.igfs.client;
-import org.apache.ignite.igfs.IgfsFile;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.util.typedef.internal.S;
http://git-wip-us.apache.org/repos/asf/ignite/blob/72b4eb58/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
index 4acf4eb..a03c7e6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
@@ -25,6 +25,8 @@ import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
@@ -75,6 +77,18 @@ public class IgfsClientUpdateCallable extends IgfsClientAbstractCallable<IgfsFil
}
/** {@inheritDoc} */
+ @Override protected byte fieldsCount0() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean writeTo0(MessageWriter writer, int fieldId) {
+ assert fieldId == 0;
+
+ return writer.writeMap("props", props, MessageCollectionItemType.STRING, MessageCollectionItemType.STRING);
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientUpdateCallable.class, this);
}
[4/6] ignite git commit: WIP. Wired all managers and context.
Posted by vo...@apache.org.
WIP. Wired all managers and context.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/77d213ea
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/77d213ea
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/77d213ea
Branch: refs/heads/ignite-3553
Commit: 77d213ea80a052efd649193d5e9661e6f180a2df
Parents: bb6e87a
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Jul 26 15:01:28 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Jul 26 15:01:28 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsContext.java | 17 +++++++
.../processors/igfs/IgfsDataManager.java | 35 +++++++++-----
.../igfs/IgfsFragmentizerManager.java | 41 ++++++++++------
.../internal/processors/igfs/IgfsManager.java | 22 +++++++--
.../processors/igfs/IgfsMetaManager.java | 31 ++++++------
.../internal/processors/igfs/IgfsProcessor.java | 26 +++++++---
.../processors/igfs/IgfsServerManager.java | 13 ++++-
.../igfs/client/IgfsClientClosureManager.java | 51 ++++++++++++--------
.../igfs/client/IgfsClientClosureResponse.java | 2 +-
9 files changed, 160 insertions(+), 78 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/77d213ea/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsContext.java
index a638bf3..3f67156 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsContext.java
@@ -24,6 +24,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.igfs.client.IgfsClientClosureManager;
import org.jetbrains.annotations.Nullable;
/**
@@ -39,6 +40,9 @@ public class IgfsContext {
/** Managers. */
private List<IgfsManager> mgrs = new LinkedList<>();
+ /** Closure manager. */
+ private final IgfsClientClosureManager cloMgr;
+
/** Meta manager. */
private final IgfsMetaManager metaMgr;
@@ -55,8 +59,11 @@ public class IgfsContext {
private final IgfsEx igfs;
/**
+ * Constructor.
+ *
* @param ctx Kernal context.
* @param cfg IGFS configuration.
+ * @param cloMgr Closure manager.
* @param metaMgr Meta manager.
* @param dataMgr Data manager.
* @param srvMgr Server manager.
@@ -66,6 +73,7 @@ public class IgfsContext {
public IgfsContext(
GridKernalContext ctx,
FileSystemConfiguration cfg,
+ IgfsClientClosureManager cloMgr,
IgfsMetaManager metaMgr,
IgfsDataManager dataMgr,
IgfsServerManager srvMgr,
@@ -74,6 +82,8 @@ public class IgfsContext {
this.ctx = ctx;
this.cfg = cfg;
+ this.cloMgr = cloMgr;
+
this.metaMgr = add(metaMgr);
this.dataMgr = add(dataMgr);
this.srvMgr = add(srvMgr);
@@ -111,6 +121,13 @@ public class IgfsContext {
}
/**
+ * @return Closure manager.
+ */
+ public IgfsClientClosureManager closure() {
+ return cloMgr;
+ }
+
+ /**
* @return Meta manager.
*/
public IgfsMetaManager meta() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/77d213ea/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 1397e4e..07d80dd 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
@@ -33,6 +33,7 @@ import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
import org.apache.ignite.igfs.IgfsOutOfSpaceException;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadable;
+import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
@@ -143,7 +144,16 @@ public class IgfsDataManager extends IgfsManager {
new ConcurrentHashMap8<>();
/**
+ * Constructor.
*
+ * @param ctx Kernal context.
+ */
+ public IgfsDataManager(GridKernalContext ctx) {
+ super(ctx);
+ }
+
+ /**
+ * Await data cache initiaization.
*/
void awaitInit() {
try {
@@ -162,7 +172,7 @@ public class IgfsDataManager extends IgfsManager {
topic = F.isEmpty(igfsName) ? TOPIC_IGFS : TOPIC_IGFS.topic(igfsName);
- igfsCtx.kernalContext().io().addMessageListener(topic, new GridMessageListener() {
+ ctx.io().addMessageListener(topic, new GridMessageListener() {
@Override public void onMessage(UUID nodeId, Object msg) {
if (msg instanceof IgfsBlocksMessage)
processBlocksMessage(nodeId, (IgfsBlocksMessage)msg);
@@ -171,7 +181,7 @@ public class IgfsDataManager extends IgfsManager {
}
});
- igfsCtx.kernalContext().event().addLocalEventListener(new GridLocalEventListener() {
+ ctx.event().addLocalEventListener(new GridLocalEventListener() {
@Override public void onEvent(Event evt) {
assert evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT;
@@ -186,16 +196,15 @@ public class IgfsDataManager extends IgfsManager {
}
}, EVT_NODE_LEFT, EVT_NODE_FAILED);
- igfsSvc = igfsCtx.kernalContext().getIgfsExecutorService();
+ igfsSvc = ctx.getIgfsExecutorService();
- delWorker = new AsyncDeleteWorker(igfsCtx.kernalContext().gridName(),
- "igfs-" + igfsName + "-delete-worker", log);
+ delWorker = new AsyncDeleteWorker(ctx.gridName(), "igfs-" + igfsName + "-delete-worker", log);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected void onKernalStart0() throws IgniteCheckedException {
- dataCachePrj = igfsCtx.kernalContext().cache().getOrStartCache(igfsCtx.configuration().getDataCacheName());
+ dataCachePrj = ctx.cache().getOrStartCache(igfsCtx.configuration().getDataCacheName());
assert dataCachePrj != null;
@@ -203,7 +212,7 @@ public class IgfsDataManager extends IgfsManager {
metrics = igfsCtx.igfs().localMetrics();
- AffinityKeyMapper mapper = igfsCtx.kernalContext().cache()
+ AffinityKeyMapper mapper = ctx.cache()
.internalCache(igfsCtx.configuration().getDataCacheName()).configuration().getAffinityMapper();
grpSize = mapper instanceof IgfsGroupDataBlocksKeyMapper ?
@@ -213,7 +222,7 @@ public class IgfsDataManager extends IgfsManager {
assert grpBlockSize != 0;
- igfsCtx.kernalContext().cache().internalCache(igfsCtx.configuration().getDataCacheName()).preloader()
+ ctx.cache().internalCache(igfsCtx.configuration().getDataCacheName()).preloader()
.startFuture().listen(new CI1<IgniteInternalFuture<Object>>() {
@Override public void apply(IgniteInternalFuture<Object> f) {
dataCacheStartLatch.countDown();
@@ -266,7 +275,7 @@ public class IgfsDataManager extends IgfsManager {
if (!dataCache.context().affinityNode())
return null;
- UUID nodeId = igfsCtx.kernalContext().localNodeId();
+ UUID nodeId = ctx.localNodeId();
if (prevAffKey != null && dataCache.affinity().mapKeyToNode(prevAffKey).isLocal())
return prevAffKey;
@@ -296,7 +305,7 @@ public class IgfsDataManager extends IgfsManager {
*/
private IgniteDataStreamer<IgfsBlockKey, byte[]> dataStreamer() {
IgniteDataStreamer<IgfsBlockKey, byte[]> ldr =
- igfsCtx.kernalContext().<IgfsBlockKey, byte[]>dataStream().dataStreamer(dataCachePrj.name());
+ ctx.<IgfsBlockKey, byte[]>dataStream().dataStreamer(dataCachePrj.name());
FileSystemConfiguration cfg = igfsCtx.configuration();
@@ -331,7 +340,7 @@ public class IgfsDataManager extends IgfsManager {
final IgfsBlockKey key = blockKey(blockIdx, fileInfo);
if (log.isDebugEnabled() &&
- dataCache.affinity().isPrimaryOrBackup(igfsCtx.kernalContext().discovery().localNode(), key)) {
+ dataCache.affinity().isPrimaryOrBackup(ctx.discovery().localNode(), key)) {
log.debug("Reading non-local data block [path=" + path + ", fileInfo=" + fileInfo +
", blockIdx=" + blockIdx + ']');
}
@@ -1022,7 +1031,7 @@ public class IgfsDataManager extends IgfsManager {
", allowed=" + dataCachePrj.igfsDataSpaceMax() + ']');
completionFut.onDone(new IgniteCheckedException("Failed to write data (not enough space on node): " +
- igfsCtx.kernalContext().localNodeId(), e));
+ ctx.localNodeId(), e));
return;
}
@@ -1149,7 +1158,7 @@ public class IgfsDataManager extends IgfsManager {
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
private void processAckMessage(UUID nodeId, IgfsAckMessage ackMsg) {
try {
- ackMsg.finishUnmarshal(igfsCtx.kernalContext().config().getMarshaller(), null);
+ ackMsg.finishUnmarshal(ctx.config().getMarshaller(), null);
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to unmarshal message (will ignore): " + ackMsg, e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/77d213ea/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
index d64c64a..2e3843c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
@@ -22,6 +22,7 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
+import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.managers.communication.GridMessageListener;
@@ -99,13 +100,22 @@ public class IgfsFragmentizerManager extends IgfsManager {
/** Message topic. */
private Object topic;
+ /**
+ * Constructor.
+ *
+ * @param ctx Kernal context.
+ */
+ public IgfsFragmentizerManager(GridKernalContext ctx) {
+ super(ctx);
+ }
+
/** {@inheritDoc} */
@Override protected void start0() throws IgniteCheckedException {
if (!igfsCtx.configuration().isFragmentizerEnabled())
return;
// We care only about node leave and fail events.
- igfsCtx.kernalContext().event().addLocalEventListener(new GridLocalEventListener() {
+ ctx.event().addLocalEventListener(new GridLocalEventListener() {
@Override public void onEvent(Event evt) {
assert evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED;
@@ -121,7 +131,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
topic = F.isEmpty(igfsName) ? TOPIC_IGFS : TOPIC_IGFS.topic(igfsName);
- igfsCtx.kernalContext().io().addMessageListener(topic, fragmentizerWorker);
+ ctx.io().addMessageListener(topic, fragmentizerWorker);
new IgniteThread(fragmentizerWorker).start();
}
@@ -130,7 +140,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
@Override protected void onKernalStart0() throws IgniteCheckedException {
if (igfsCtx.configuration().isFragmentizerEnabled()) {
// Check at startup if this node is a fragmentizer coordinator.
- DiscoveryEvent locJoinEvt = igfsCtx.kernalContext().discovery().localJoinEvent();
+ DiscoveryEvent locJoinEvt = ctx.discovery().localJoinEvent();
checkLaunchCoordinator(locJoinEvt);
}
@@ -191,7 +201,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
return;
}
catch (IgniteCheckedException e) {
- if (!igfsCtx.kernalContext().discovery().alive(nodeId))
+ if (!ctx.discovery().alive(nodeId))
throw new ClusterTopologyCheckedException("Failed to send message (node left the grid) " +
"[nodeId=" + nodeId + ", msg=" + msg + ']');
@@ -226,7 +236,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
minNodeOrder = node.order();
}
- ClusterNode locNode = igfsCtx.kernalContext().grid().localNode();
+ ClusterNode locNode = ctx.grid().localNode();
if (locNode.order() == minNodeOrder) {
if (log.isDebugEnabled())
@@ -263,7 +273,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
*/
@SuppressWarnings("fallthrough")
private void processFragmentizerRequest(IgfsFragmentizerRequest req) throws IgniteCheckedException {
- req.finishUnmarshal(igfsCtx.kernalContext().config().getMarshaller(), null);
+ req.finishUnmarshal(ctx.config().getMarshaller(), null);
Collection<IgfsFileAffinityRange> ranges = req.fragmentRanges();
IgniteUuid fileId = req.fileId();
@@ -356,11 +366,11 @@ public class IgfsFragmentizerManager extends IgfsManager {
* Constructor.
*/
protected FragmentizerCoordinator() {
- super(igfsCtx.kernalContext().gridName(), "fragmentizer-coordinator",
- igfsCtx.kernalContext().log(IgfsFragmentizerManager.class));
+ super(ctx.gridName(), "fragmentizer-coordinator",
+ ctx.log(IgfsFragmentizerManager.class));
- igfsCtx.kernalContext().event().addLocalEventListener(this, EVT_NODE_LEFT, EVT_NODE_FAILED);
- igfsCtx.kernalContext().io().addMessageListener(topic, this);
+ ctx.event().addLocalEventListener(this, EVT_NODE_LEFT, EVT_NODE_FAILED);
+ ctx.io().addMessageListener(topic, this);
}
/** {@inheritDoc} */
@@ -481,7 +491,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
else if (msg instanceof IgfsSyncMessage) {
IgfsSyncMessage sync = (IgfsSyncMessage)msg;
- if (sync.response() && sync.order() == igfsCtx.kernalContext().grid().localNode().order()) {
+ if (sync.response() && sync.order() == ctx.grid().localNode().order()) {
if (log.isDebugEnabled())
log.debug("Received fragmentizer sync response from remote node: " + nodeId);
@@ -523,7 +533,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
private void syncStart() throws InterruptedException {
Collection<UUID> startSync0 = startSync = new GridConcurrentHashSet<>(
F.viewReadOnly(
- igfsCtx.kernalContext().discovery().allNodes(),
+ ctx.discovery().allNodes(),
F.node2id(),
new P1<ClusterNode>() {
@Override public boolean apply(ClusterNode n) {
@@ -531,7 +541,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
}
}));
- ClusterNode locNode = igfsCtx.kernalContext().grid().localNode();
+ ClusterNode locNode = ctx.grid().localNode();
while (!startSync0.isEmpty()) {
for (UUID nodeId : startSync0) {
@@ -545,7 +555,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
sendWithRetries(nodeId, syncReq);
// Close window between message sending and discovery event.
- if (!igfsCtx.kernalContext().discovery().alive(nodeId))
+ if (!ctx.discovery().alive(nodeId))
startSync0.remove(nodeId);
}
catch (IgniteCheckedException e) {
@@ -669,8 +679,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
* Constructor.
*/
protected FragmentizerWorker() {
- super(igfsCtx.kernalContext().gridName(), "fragmentizer-worker",
- igfsCtx.kernalContext().log(IgfsFragmentizerManager.class));
+ super(ctx.gridName(), "fragmentizer-worker", ctx.log(IgfsFragmentizerManager.class));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/77d213ea/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsManager.java
index cdd277b..56e561b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsManager.java
@@ -20,12 +20,17 @@ package org.apache.ignite.internal.processors.igfs;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.GridKernalContext;
+import org.jetbrains.annotations.Nullable;
/**
* Abstract class for IGFS managers.
*/
public abstract class IgfsManager {
- /** IGFS context. */
+ /** Kernal context. */
+ protected final GridKernalContext ctx;
+
+ /** IGFS context (not set for shared managers). */
protected IgfsContext igfsCtx;
/** Logger. */
@@ -35,19 +40,26 @@ public abstract class IgfsManager {
private AtomicBoolean starting = new AtomicBoolean();
/**
+ * Constructor.
+ *
+ * @param ctx Kernal context.
+ */
+ protected IgfsManager(GridKernalContext ctx) {
+ this.ctx = ctx;
+ }
+
+ /**
* Called when IGFS processor is started.
*
* @param igfsCtx IGFS context.
*/
- public void start(IgfsContext igfsCtx) throws IgniteCheckedException {
+ public void start(@Nullable IgfsContext igfsCtx) throws IgniteCheckedException {
if (!starting.compareAndSet(false, true))
assert false : "Method start is called more than once for manager: " + this;
- assert igfsCtx != null;
-
this.igfsCtx = igfsCtx;
- log = igfsCtx.kernalContext().log(getClass());
+ log = ctx.log(getClass());
start0();
http://git-wip-us.apache.org/repos/asf/ignite/blob/77d213ea/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 d891b38..06d65fe 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
@@ -40,6 +40,7 @@ import org.apache.ignite.igfs.IgfsPathIsNotDirectoryException;
import org.apache.ignite.igfs.IgfsPathNotFoundException;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadable;
+import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
@@ -159,7 +160,9 @@ public class IgfsMetaManager extends IgfsManager {
* @param relaxed Relaxed mode flag.
* @param client Client flag.
*/
- public IgfsMetaManager(boolean relaxed, boolean client) {
+ public IgfsMetaManager(GridKernalContext ctx, boolean relaxed, boolean client) {
+ super(ctx);
+
this.relaxed = relaxed;
this.client = client;
}
@@ -182,21 +185,21 @@ public class IgfsMetaManager extends IgfsManager {
cfg = igfsCtx.configuration();
- evts = igfsCtx.kernalContext().event();
+ evts = ctx.event();
sampling = new IgfsSamplingKey(cfg.getName());
- log = igfsCtx.kernalContext().log(IgfsMetaManager.class);
+ log = ctx.log(IgfsMetaManager.class);
}
/** {@inheritDoc} */
@SuppressWarnings("RedundantCast")
@Override protected void onKernalStart0() throws IgniteCheckedException {
- metaCache = igfsCtx.kernalContext().cache().getOrStartCache(cfg.getMetaCacheName());
+ metaCache = ctx.cache().getOrStartCache(cfg.getMetaCacheName());
assert metaCache != null;
- igfsCtx.kernalContext().cache().internalCache(cfg.getMetaCacheName()).preloader().startFuture()
+ ctx.cache().internalCache(cfg.getMetaCacheName()).preloader().startFuture()
.listen(new CI1<IgniteInternalFuture<Object>>() {
@Override public void apply(IgniteInternalFuture<Object> f) {
metaCacheStartLatch.countDown();
@@ -205,7 +208,7 @@ public class IgfsMetaManager extends IgfsManager {
id2InfoPrj = (IgniteInternalCache<IgniteUuid, IgfsEntryInfo>)metaCache.<IgniteUuid, IgfsEntryInfo>cache();
- locNode = igfsCtx.kernalContext().discovery().localNode();
+ locNode = ctx.discovery().localNode();
// Start background delete worker.
if (!client) {
@@ -266,7 +269,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteCompute cliCompute0 = cliCompute;
if (cliCompute0 == null) {
- IgniteEx ignite = igfsCtx.kernalContext().grid();
+ IgniteEx ignite = ctx.grid();
ClusterGroup cluster = ignite.cluster().forIgfsMetadataDataNodes(cfg.getName(), cfg.getMetaCacheName());
@@ -1011,7 +1014,7 @@ public class IgfsMetaManager extends IgfsManager {
// Fire events.
IgfsPath newPath = new IgfsPath(dstPathIds.path(), dstName);
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), srcPath, newPath,
+ IgfsUtils.sendEvents(ctx, srcPath, newPath,
srcInfo.isFile() ? EVT_IGFS_FILE_RENAMED : EVT_IGFS_DIR_RENAMED);
}
}
@@ -2916,7 +2919,7 @@ public class IgfsMetaManager extends IgfsManager {
tx.commit();
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EventType.EVT_IGFS_FILE_OPENED_WRITE);
+ IgfsUtils.sendEvents(ctx, path, EventType.EVT_IGFS_FILE_OPENED_WRITE);
return info;
}
@@ -3081,7 +3084,7 @@ public class IgfsMetaManager extends IgfsManager {
// Prepare result and commit.
tx.commit();
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EventType.EVT_IGFS_FILE_OPENED_WRITE);
+ IgfsUtils.sendEvents(ctx, path, EventType.EVT_IGFS_FILE_OPENED_WRITE);
return new IgfsCreateResult(newInfo, secondaryOut);
}
@@ -3368,18 +3371,18 @@ public class IgfsMetaManager extends IgfsManager {
private void generateCreateEvents(List<IgfsPath> createdPaths, boolean file) {
if (evts.isRecordable(EventType.EVT_IGFS_DIR_CREATED)) {
for (int i = 0; i < createdPaths.size() - 1; i++)
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), createdPaths.get(i),
+ IgfsUtils.sendEvents(ctx, createdPaths.get(i),
EventType.EVT_IGFS_DIR_CREATED);
}
IgfsPath leafPath = createdPaths.get(createdPaths.size() - 1);
if (file) {
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), leafPath, EventType.EVT_IGFS_FILE_CREATED);
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), leafPath, EventType.EVT_IGFS_FILE_OPENED_WRITE);
+ IgfsUtils.sendEvents(ctx, leafPath, EventType.EVT_IGFS_FILE_CREATED);
+ IgfsUtils.sendEvents(ctx, leafPath, EventType.EVT_IGFS_FILE_OPENED_WRITE);
}
else
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), leafPath, EventType.EVT_IGFS_DIR_CREATED);
+ IgfsUtils.sendEvents(ctx, leafPath, EventType.EVT_IGFS_DIR_CREATED);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/77d213ea/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
index 85dcb1c..7d6753d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
@@ -33,6 +33,7 @@ import org.apache.ignite.igfs.mapreduce.IgfsJob;
import org.apache.ignite.igfs.mapreduce.IgfsRecordResolver;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteNodeAttributes;
+import org.apache.ignite.internal.processors.igfs.client.IgfsClientClosureManager;
import org.apache.ignite.internal.processors.query.GridQueryProcessor;
import org.apache.ignite.internal.util.ipc.IpcServerEndpoint;
import org.apache.ignite.internal.util.typedef.C1;
@@ -83,11 +84,16 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
private final ConcurrentMap<String, IgfsContext> igfsCache =
new ConcurrentHashMap8<>();
+ /** Client closure manager. */
+ private final IgfsClientClosureManager cloMgr;
+
/**
* @param ctx Kernal context.
*/
public IgfsProcessor(GridKernalContext ctx) {
super(ctx);
+
+ cloMgr = new IgfsClientClosureManager(ctx);
}
/** {@inheritDoc} */
@@ -127,10 +133,11 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
IgfsContext igfsCtx = new IgfsContext(
ctx,
cfg0,
- new IgfsMetaManager(cfg0.isRelaxedConsistency(), metaClient),
- new IgfsDataManager(),
- new IgfsServerManager(),
- new IgfsFragmentizerManager());
+ cloMgr,
+ new IgfsMetaManager(ctx, cfg0.isRelaxedConsistency(), metaClient),
+ new IgfsDataManager(ctx),
+ new IgfsServerManager(ctx),
+ new IgfsFragmentizerManager(ctx));
// Start managers first.
for (IgfsManager mgr : igfsCtx.managers())
@@ -139,6 +146,9 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
igfsCache.put(maskName(cfg0.getName()), igfsCtx);
}
+ // Start closure manager last.
+ cloMgr.start(null);
+
if (log.isDebugEnabled())
log.debug("IGFS processor started.");
@@ -201,10 +211,14 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
for (IgfsContext igfsCtx : igfsCache.values())
for (IgfsManager mgr : igfsCtx.managers())
mgr.onKernalStart();
+
+ cloMgr.onKernalStart();
}
/** {@inheritDoc} */
@Override public void stop(boolean cancel) {
+ cloMgr.stop(cancel);
+
// Stop IGFS instances.
for (IgfsContext igfsCtx : igfsCache.values()) {
if (log.isDebugEnabled())
@@ -229,6 +243,8 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
/** {@inheritDoc} */
@Override public void onKernalStop(boolean cancel) {
+ cloMgr.onKernalStop(cancel);
+
for (IgfsContext igfsCtx : igfsCache.values()) {
if (log.isDebugEnabled())
log.debug("Stopping igfs: " + igfsCtx.configuration().getName());
@@ -389,8 +405,6 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
if (F.isEmpty(locAttrs) || F.isEmpty(rmtAttrs))
return;
- assert rmtAttrs != null && locAttrs != null;
-
for (IgfsAttributes rmtAttr : rmtAttrs)
for (IgfsAttributes locAttr : locAttrs) {
// Checking the use of different caches on the different IGFSes.
http://git-wip-us.apache.org/repos/asf/ignite/blob/77d213ea/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServerManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServerManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServerManager.java
index c12b367..debc590 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServerManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServerManager.java
@@ -25,6 +25,7 @@ import java.util.concurrent.CountDownLatch;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.igfs.IgfsIpcEndpointConfiguration;
+import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.util.ipc.IpcEndpointBindException;
import org.apache.ignite.internal.util.ipc.IpcServerEndpoint;
import org.apache.ignite.internal.util.typedef.C1;
@@ -52,6 +53,15 @@ public class IgfsServerManager extends IgfsManager {
/** Kernal start latch. */
private CountDownLatch kernalStartLatch = new CountDownLatch(1);
+ /**
+ * Constructor.
+ *
+ * @param ctx Kernal context.
+ */
+ public IgfsServerManager(GridKernalContext ctx) {
+ super(ctx);
+ }
+
/** {@inheritDoc} */
@Override protected void start0() throws IgniteCheckedException {
FileSystemConfiguration igfsCfg = igfsCtx.configuration();
@@ -163,8 +173,7 @@ public class IgfsServerManager extends IgfsManager {
* Constructor.
*/
private BindWorker() {
- super(igfsCtx.kernalContext().gridName(), "bind-worker",
- igfsCtx.kernalContext().log(IgfsServerManager.class));
+ super(ctx.gridName(), "bind-worker", ctx.log(IgfsServerManager.class));
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/77d213ea/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
index 7230cf2..9e0f044 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
@@ -18,9 +18,9 @@
package org.apache.ignite.internal.processors.igfs.client;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.processors.igfs.IgfsManager;
import org.apache.ignite.internal.util.GridStripedSpinBusyLock;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -38,24 +38,23 @@ public class IgfsClientClosureManager extends IgfsManager {
/** Pending closures received when manager is not started yet. */
private final ConcurrentLinkedDeque startupClos = new ConcurrentLinkedDeque();
- /** Kernal context. */
- private GridKernalContext ctx;
-
- /** IGFS configuration. */
- private FileSystemConfiguration igfsCfg;
-
/** Marshaller. */
- private Marshaller marsh;
-
- /** {@inheritDoc} */
- @Override protected void start0() throws IgniteCheckedException {
- ctx = igfsCtx.kernalContext();
+ private final Marshaller marsh;
- igfsCfg = igfsCtx.configuration();
+ /**
+ * Constructor.
+ *
+ * @param ctx Kernal context.
+ */
+ public IgfsClientClosureManager(GridKernalContext ctx) {
+ super(ctx);
marsh = ctx.config().getMarshaller();
+ }
- ctx.discovery().setCustomEventListener();
+ /** {@inheritDoc} */
+ @Override protected void start0() throws IgniteCheckedException {
+ // TODO
}
/** {@inheritDoc} */
@@ -74,21 +73,31 @@ public class IgfsClientClosureManager extends IgfsManager {
}
/**
- * Execute callable.
+ * Execute IGFS closure.
*
+ * @param igfsCtx IGFS context.
* @param clo Closure.
* @return Result.
*/
- public <T> T execute(IgfsClientAbstractCallable<T> clo) {
+ public <T> T execute(IgfsContext igfsCtx, IgfsClientAbstractCallable<T> clo) throws IgniteCheckedException {
+ return executeAsync(igfsCtx, clo).get();
+ }
+ /**
+ * Execute IGFS closure asynchronously.
+ *
+ * @param igfsCtx IGFS context.
+ * @param clo Closure.
+ * @return Future.
+ */
+ public <T> IgniteInternalFuture<T> executeAsync(IgfsContext igfsCtx, IgfsClientAbstractCallable<T> clo) {
+ // TODO
+
+ return null;
}
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientClosureManager.class, this);
}
-
- private class DiscoveryListener implements GridLocalEventListener {
-
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/77d213ea/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java
index 3a7694a..d768766 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java
@@ -20,7 +20,7 @@ package org.apache.ignite.internal.processors.igfs.client;
import org.apache.ignite.plugin.extensions.communication.Message;
/**
- * CIGFS client closure execute response.
+ * IGFS client closure execute response.
*/
public class IgfsClientClosureResponse implements Message {
/**
[6/6] ignite git commit: WIP on response structure.
Posted by vo...@apache.org.
WIP on response structure.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/07f10301
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/07f10301
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/07f10301
Branch: refs/heads/ignite-3553
Commit: 07f103018b96bf2d846e2d5549040e75faaf0258
Parents: 197a572
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Jul 27 07:57:44 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Jul 27 07:57:44 2016 +0300
----------------------------------------------------------------------
.../igfs/client/IgfsClientClosureManager.java | 35 +++++++
.../igfs/client/IgfsClientClosureResponse.java | 97 ++++++++++++++++++++
.../client/IgfsClientClosureResponseType.java | 53 +++++++++++
3 files changed, 185 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/07f10301/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
index d37f741..bdd5ed7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
@@ -24,7 +24,9 @@ import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.processors.igfs.IgfsManager;
import org.apache.ignite.internal.util.GridStripedSpinBusyLock;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
+import org.jetbrains.annotations.Nullable;
import java.util.concurrent.ConcurrentLinkedDeque;
@@ -96,6 +98,39 @@ public class IgfsClientClosureManager extends IgfsManager {
return null;
}
+ /**
+ * Create closure response.
+ *
+ * @param msgId Message ID.
+ * @param res Response.
+ * @param marsh Marshaller.
+ * @return Response.
+ */
+ public IgfsClientClosureResponse createResponse(long msgId, @Nullable Object res, @Nullable Throwable resErr,
+ Marshaller marsh) {
+ try {
+
+ if (resErr != null)
+ return new IgfsClientClosureResponse(msgId, IgfsClientClosureResponseType.ERR, null,
+ marsh.marshal(resErr));
+ else {
+ if (res == null)
+ return new IgfsClientClosureResponse(msgId, IgfsClientClosureResponseType.NULL, null, null);
+ else if (res instanceof Boolean)
+ return new IgfsClientClosureResponse(msgId, IgfsClientClosureResponseType.BOOL, res, null);
+ else
+ return new IgfsClientClosureResponse(msgId, IgfsClientClosureResponseType.OBJ, null,
+ marsh.marshal(res));
+ }
+ }
+ catch (Exception e) {
+ U.error(log, "Failed to marshal IGFS closure result [msgId=" + msgId + ", res=" + res +
+ ", resErr=" + resErr + ']', e);
+
+ return new IgfsClientClosureResponse(msgId, IgfsClientClosureResponseType.MARSH_ERR, null, null);
+ }
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientClosureManager.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/07f10301/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java
index d768766..7d0d0d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponse.java
@@ -17,16 +17,113 @@
package org.apache.ignite.internal.processors.igfs.client;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
+import org.jetbrains.annotations.Nullable;
+
+import java.nio.ByteBuffer;
/**
* IGFS client closure execute response.
*/
public class IgfsClientClosureResponse implements Message {
+ /** Message ID. */
+ private long msgId;
+
+ /** Response type. */
+ private IgfsClientClosureResponseType typ;
+
+ /** Result. */
+ private Object res;
+
+ /** Result bytes. */
+ private byte[] resBytes;
+
/**
* Default constructor.
*/
public IgfsClientClosureResponse() {
// No-op.
}
+
+ /**
+ * Constructor.
+ *
+ * @param msgId Message ID.
+ * @param typ Type.
+ * @param res Result.
+ * @param resBytes Result bytes.
+ */
+ public IgfsClientClosureResponse(long msgId, IgfsClientClosureResponseType typ, @Nullable Object res,
+ @Nullable byte[] resBytes) {
+ this.msgId = msgId;
+ this.typ = typ;
+ this.res = res;
+ this.resBytes = resBytes;
+ }
+
+ /**
+ * @return Message ID.
+ */
+ public long messageId() {
+ return msgId;
+ }
+
+ /**
+ * @return Type.
+ */
+ public IgfsClientClosureResponseType type() {
+ return typ;
+ }
+
+ /**
+ * @return Result.
+ */
+ @Nullable public Object result() {
+ return res;
+ }
+
+ /**
+ * @return Result bytes.
+ */
+ @Nullable public byte[] resultBytes() {
+ return resBytes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte directType() {
+ return -28;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte fieldsCount() {
+ return (byte)(typ == IgfsClientClosureResponseType.NULL || typ == IgfsClientClosureResponseType.MARSH_ERR ?
+ 2 : 3);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onAckReceived() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
+ // TODO
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
+ // TODO
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsClientClosureResponse.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/07f10301/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponseType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponseType.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponseType.java
new file mode 100644
index 0000000..8fd45c9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureResponseType.java
@@ -0,0 +1,53 @@
+/*
+ * 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.igfs.client;
+
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * IGFS client closure response type.
+ */
+public enum IgfsClientClosureResponseType {
+ /** Object. */
+ OBJ,
+
+ /** Null result. */
+ NULL,
+
+ /** Boolean result. */
+ BOOL,
+
+ /** Error. */
+ ERR,
+
+ /** Marshalling error. */
+ MARSH_ERR;
+
+ /** Enum values. */
+ private static final IgfsClientClosureResponseType[] VALS = values();
+
+ /**
+ * Efficiently gets enumerated value from its ordinal.
+ *
+ * @param ord Ordinal value.
+ * @return Enumerated value.
+ */
+ @Nullable public static IgfsClientClosureResponseType fromOrdinal(int ord) {
+ return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
+ }
+}
[5/6] ignite git commit: Minors.
Posted by vo...@apache.org.
Minors.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/197a5728
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/197a5728
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/197a5728
Branch: refs/heads/ignite-3553
Commit: 197a5728274b377496bc29e7ceba26f90dd73c93
Parents: 77d213e
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Jul 26 15:03:42 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Jul 26 15:03:42 2016 +0300
----------------------------------------------------------------------
.../processors/igfs/client/IgfsClientClosureManager.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/197a5728/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
index 9e0f044..d37f741 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureManager.java
@@ -32,15 +32,15 @@ import java.util.concurrent.ConcurrentLinkedDeque;
* Manager to handle IGFS client closures.
*/
public class IgfsClientClosureManager extends IgfsManager {
- /** Busy lock. */
- private final GridStripedSpinBusyLock busyLock = new GridStripedSpinBusyLock();
-
/** Pending closures received when manager is not started yet. */
private final ConcurrentLinkedDeque startupClos = new ConcurrentLinkedDeque();
/** Marshaller. */
private final Marshaller marsh;
+ /** Stopping flag. */
+ private volatile boolean stopping;
+
/**
* Constructor.
*
[3/6] ignite git commit: WIP. Implemented message read logic.
Posted by vo...@apache.org.
WIP. Implemented message read logic.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bb6e87a1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bb6e87a1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bb6e87a1
Branch: refs/heads/ignite-3553
Commit: bb6e87a1003e43bd8daa95e8a92a147b706485f6
Parents: 72b4eb5
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Jul 26 12:39:56 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Jul 26 12:39:56 2016 +0300
----------------------------------------------------------------------
.../igfs/client/IgfsClientAbstractCallable.java | 107 ++++++++++++++++++-
.../igfs/client/IgfsClientAffinityCallable.java | 22 +++-
.../igfs/client/IgfsClientClosureRequest.java | 63 ++++++++++-
.../igfs/client/IgfsClientDeleteCallable.java | 13 ++-
.../igfs/client/IgfsClientExistsCallable.java | 5 +-
.../igfs/client/IgfsClientInfoCallable.java | 5 +-
.../client/IgfsClientListFilesCallable.java | 5 +-
.../client/IgfsClientListPathsCallable.java | 5 +-
.../igfs/client/IgfsClientMkdirsCallable.java | 13 ++-
.../igfs/client/IgfsClientRenameCallable.java | 16 ++-
.../igfs/client/IgfsClientSetTimesCallable.java | 19 +++-
.../igfs/client/IgfsClientSizeCallable.java | 5 +-
.../igfs/client/IgfsClientSummaryCallable.java | 5 +-
.../igfs/client/IgfsClientUpdateCallable.java | 13 ++-
.../meta/IgfsClientMetaIdsForPathCallable.java | 5 +-
.../meta/IgfsClientMetaInfoForPathCallable.java | 5 +-
16 files changed, 288 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
index 85d4aea..a184f2e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAbstractCallable.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.igfs.client;
import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryRawReader;
import org.apache.ignite.binary.BinaryRawWriter;
@@ -28,7 +29,10 @@ import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.processors.igfs.IgfsEx;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
+import org.apache.ignite.internal.processors.igfs.client.meta.IgfsClientMetaIdsForPathCallable;
+import org.apache.ignite.internal.processors.igfs.client.meta.IgfsClientMetaInfoForPathCallable;
import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.jetbrains.annotations.Nullable;
@@ -43,8 +47,11 @@ public abstract class IgfsClientAbstractCallable<T> implements IgniteCallable<T>
/** Base fields count. */
private static final byte BASE_FIELDS_CNT = 2;
+ /** Type ID. */
+ private short typeId;
+
/** IGFS name. */
- protected String igfsName;
+ private String igfsName;
/** Path for operation. */
protected IgfsPath path;
@@ -54,6 +61,61 @@ public abstract class IgfsClientAbstractCallable<T> implements IgniteCallable<T>
private transient Ignite ignite;
/**
+ * Create callable for the given type ID.
+ *
+ * @param typeId Type ID.
+ * @return Callable.
+ */
+ public static IgfsClientAbstractCallable callableForTypeId(short typeId) {
+ switch (typeId) {
+ case IgfsClientMetaIdsForPathCallable.TYPE_ID:
+ return new IgfsClientMetaIdsForPathCallable();
+
+ case IgfsClientMetaInfoForPathCallable.TYPE_ID:
+ return new IgfsClientMetaInfoForPathCallable();
+
+ case IgfsClientAffinityCallable.TYPE_ID:
+ return new IgfsClientAffinityCallable();
+
+ case IgfsClientDeleteCallable.TYPE_ID:
+ return new IgfsClientDeleteCallable();
+
+ case IgfsClientExistsCallable.TYPE_ID:
+ return new IgfsClientExistsCallable();
+
+ case IgfsClientInfoCallable.TYPE_ID:
+ return new IgfsClientInfoCallable();
+
+ case IgfsClientListFilesCallable.TYPE_ID:
+ return new IgfsClientListFilesCallable();
+
+ case IgfsClientListPathsCallable.TYPE_ID:
+ return new IgfsClientListPathsCallable();
+
+ case IgfsClientMkdirsCallable.TYPE_ID:
+ return new IgfsClientMkdirsCallable();
+
+ case IgfsClientRenameCallable.TYPE_ID:
+ return new IgfsClientRenameCallable();
+
+ case IgfsClientSetTimesCallable.TYPE_ID:
+ return new IgfsClientUpdateCallable();
+
+ case IgfsClientSizeCallable.TYPE_ID:
+ return new IgfsClientSizeCallable();
+
+ case IgfsClientSummaryCallable.TYPE_ID:
+ return new IgfsClientSummaryCallable();
+
+ case IgfsClientUpdateCallable.TYPE_ID:
+ return new IgfsClientUpdateCallable();
+
+ default:
+ throw new IgniteException("Unsupported IGFS callable type ID: " + typeId);
+ }
+ }
+
+ /**
* Default constructor.
*/
protected IgfsClientAbstractCallable() {
@@ -63,10 +125,12 @@ public abstract class IgfsClientAbstractCallable<T> implements IgniteCallable<T>
/**
* Constructor.
*
+ * @param typeId Type ID.
* @param igfsName IGFS name.
* @param path Path.
*/
- protected IgfsClientAbstractCallable(@Nullable String igfsName, @Nullable IgfsPath path) {
+ protected IgfsClientAbstractCallable(short typeId, @Nullable String igfsName, @Nullable IgfsPath path) {
+ this.typeId = typeId;
this.igfsName = igfsName;
this.path = path;
}
@@ -128,6 +192,13 @@ public abstract class IgfsClientAbstractCallable<T> implements IgniteCallable<T>
}
/**
+ * @return Type ID.
+ */
+ public short typeId() {
+ return typeId;
+ }
+
+ /**
* @return Fields count.
*/
public final byte fieldsCount() {
@@ -173,4 +244,36 @@ public abstract class IgfsClientAbstractCallable<T> implements IgniteCallable<T>
return true;
}
+
+ /**
+ * Read callable content from reader.
+ *
+ * @param reader Reader.
+ * @param fieldId Field ID.
+ */
+ public final void readFrom(MessageReader reader, int fieldId) {
+ switch (fieldId) {
+ case 0:
+ igfsName = reader.readString("igfsName");
+
+ case 1:
+ String pathStr = reader.readString("path");
+
+ if (reader.isLastRead())
+ path = new IgfsPath(pathStr);
+
+ default:
+ readFrom0(reader, fieldId - BASE_FIELDS_CNT);
+ }
+ }
+
+ /**
+ * Read callable content from reader (for child classes).
+ *
+ * @param reader Reader.
+ * @param fieldId Field ID.
+ */
+ protected void readFrom0(MessageReader reader, int fieldId) {
+ assert false : "Should not be called.";
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
index 3a63b77..bfa573e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientAffinityCallable.java
@@ -24,6 +24,7 @@ import org.apache.ignite.igfs.IgfsBlockLocation;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
@@ -33,6 +34,9 @@ import java.util.Collection;
* IGFS client affinity callable.
*/
public class IgfsClientAffinityCallable extends IgfsClientAbstractCallable<Collection<IgfsBlockLocation>> {
+ /** Type ID. */
+ public static final short TYPE_ID = 2;
+
/** */
private static final long serialVersionUID = 0L;
@@ -62,7 +66,7 @@ public class IgfsClientAffinityCallable extends IgfsClientAbstractCallable<Colle
* @param maxLen Maximum length.
*/
public IgfsClientAffinityCallable(@Nullable String igfsName, IgfsPath path, long start, long len, long maxLen) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
this.start = start;
this.len = len;
@@ -110,6 +114,22 @@ public class IgfsClientAffinityCallable extends IgfsClientAbstractCallable<Colle
}
/** {@inheritDoc} */
+ @Override protected void readFrom0(MessageReader reader, int fieldId) {
+ switch (fieldId) {
+ case 0:
+ start = reader.readLong("start");
+
+ case 1:
+ len = reader.readLong("len");
+
+ default:
+ assert fieldId == 2;
+
+ maxLen = reader.readLong("maxLen");
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientAffinityCallable.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureRequest.java
index a0bc3f4..1eda024 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientClosureRequest.java
@@ -17,6 +17,8 @@
package org.apache.ignite.internal.processors.igfs.client;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -29,7 +31,7 @@ import java.util.UUID;
*/
public class IgfsClientClosureRequest implements Message {
/** Base fields (all except of target) count. */
- private static final byte BASE_FIELDS_CNT = 2;
+ private static final byte BASE_FIELDS_CNT = 3;
/** Originating node ID. */
private UUID nodeId;
@@ -38,6 +40,7 @@ public class IgfsClientClosureRequest implements Message {
private long msgId;
/** Target callable. */
+ @GridToStringInclude
private IgfsClientAbstractCallable target;
/**
@@ -125,6 +128,12 @@ public class IgfsClientClosureRequest implements Message {
writer.incrementState();
+ case 2:
+ if (!writer.writeShort("typeId", target.typeId()))
+ return false;
+
+ writer.incrementState();
+
default:
while (writer.state() < fieldsCount) {
if (!target.writeTo(writer, writer.state() - BASE_FIELDS_CNT))
@@ -139,6 +148,56 @@ public class IgfsClientClosureRequest implements Message {
/** {@inheritDoc} */
@Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
- return false;
+ reader.setBuffer(buf);
+
+ if (!reader.beforeMessageRead())
+ return false;
+
+ switch (reader.state()) {
+ case 0:
+ nodeId = reader.readUuid("nodeId");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 1:
+ msgId = reader.readLong("msgId");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 2:
+ short typeId;
+
+ typeId = reader.readShort("typeId");
+
+ if (!reader.isLastRead())
+ return false;
+
+ target = IgfsClientAbstractCallable.callableForTypeId(typeId);
+
+ reader.incrementState();
+
+ default:
+ while (reader.state() < fieldsCount()) {
+ target.readFrom(reader, reader.state() - BASE_FIELDS_CNT);
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+ }
+ }
+
+ return reader.afterMessageRead(IgfsClientClosureRequest.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsClientClosureRequest.class, this);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
index 9f12ea9..7cbb5f9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientDeleteCallable.java
@@ -23,6 +23,7 @@ import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
@@ -30,6 +31,9 @@ import org.jetbrains.annotations.Nullable;
* IGFS client delete callable.
*/
public class IgfsClientDeleteCallable extends IgfsClientAbstractCallable<Boolean> {
+ /** Type ID. */
+ public static final short TYPE_ID = 3;
+
/** */
private static final long serialVersionUID = 0L;
@@ -51,7 +55,7 @@ public class IgfsClientDeleteCallable extends IgfsClientAbstractCallable<Boolean
* @param recursive Recursive flag.
*/
public IgfsClientDeleteCallable(@Nullable String igfsName, IgfsPath path, boolean recursive) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
this.recursive = recursive;
}
@@ -84,6 +88,13 @@ public class IgfsClientDeleteCallable extends IgfsClientAbstractCallable<Boolean
}
/** {@inheritDoc} */
+ @Override protected void readFrom0(MessageReader reader, int fieldId) {
+ assert fieldId == 0;
+
+ recursive = reader.readBoolean("recursive");
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientDeleteCallable.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientExistsCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientExistsCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientExistsCallable.java
index 04b63d8..2eee599 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientExistsCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientExistsCallable.java
@@ -26,6 +26,9 @@ import org.jetbrains.annotations.Nullable;
* IGFS client exists callable.
*/
public class IgfsClientExistsCallable extends IgfsClientAbstractCallable<Boolean> {
+ /** Type ID. */
+ public static final short TYPE_ID = 4;
+
/** */
private static final long serialVersionUID = 0L;
@@ -43,7 +46,7 @@ public class IgfsClientExistsCallable extends IgfsClientAbstractCallable<Boolean
* @param path Path.
*/
public IgfsClientExistsCallable(@Nullable String igfsName, IgfsPath path) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientInfoCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientInfoCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientInfoCallable.java
index f97c3c4..e9821f4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientInfoCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientInfoCallable.java
@@ -27,6 +27,9 @@ import org.jetbrains.annotations.Nullable;
* IGFS client info callable.
*/
public class IgfsClientInfoCallable extends IgfsClientAbstractCallable<IgfsFile> {
+ /** Type ID. */
+ public static final short TYPE_ID = 5;
+
/** */
private static final long serialVersionUID = 0L;
@@ -44,7 +47,7 @@ public class IgfsClientInfoCallable extends IgfsClientAbstractCallable<IgfsFile>
* @param path Path.
*/
public IgfsClientInfoCallable(@Nullable String igfsName, IgfsPath path) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListFilesCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListFilesCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListFilesCallable.java
index 325e714..cb33538 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListFilesCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListFilesCallable.java
@@ -29,6 +29,9 @@ import java.util.Collection;
* IGFS client list files callable.
*/
public class IgfsClientListFilesCallable extends IgfsClientAbstractCallable<Collection<IgfsFile>> {
+ /** Type ID. */
+ public static final short TYPE_ID = 6;
+
/** */
private static final long serialVersionUID = 0L;
@@ -46,7 +49,7 @@ public class IgfsClientListFilesCallable extends IgfsClientAbstractCallable<Coll
* @param path Path.
*/
public IgfsClientListFilesCallable(@Nullable String igfsName, IgfsPath path) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListPathsCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListPathsCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListPathsCallable.java
index 78b4c84..9b347ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListPathsCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientListPathsCallable.java
@@ -28,6 +28,9 @@ import java.util.Collection;
* IGFS client list paths callable.
*/
public class IgfsClientListPathsCallable extends IgfsClientAbstractCallable<Collection<IgfsPath>> {
+ /** Type ID. */
+ public static final short TYPE_ID = 7;
+
/** */
private static final long serialVersionUID = 0L;
@@ -45,7 +48,7 @@ public class IgfsClientListPathsCallable extends IgfsClientAbstractCallable<Coll
* @param path Path.
*/
public IgfsClientListPathsCallable(@Nullable String igfsName, IgfsPath path) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
index e8ca351..e0b8495 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientMkdirsCallable.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
@@ -34,6 +35,9 @@ import java.util.Map;
* IGFS client mkdirs callable.
*/
public class IgfsClientMkdirsCallable extends IgfsClientAbstractCallable<Void> {
+ /** Type ID. */
+ public static final short TYPE_ID = 8;
+
/** */
private static final long serialVersionUID = 0L;
@@ -55,7 +59,7 @@ public class IgfsClientMkdirsCallable extends IgfsClientAbstractCallable<Void> {
* @param props Properties.
*/
public IgfsClientMkdirsCallable(@Nullable String igfsName, IgfsPath path, @Nullable Map<String, String> props) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
this.props = props;
}
@@ -90,6 +94,13 @@ public class IgfsClientMkdirsCallable extends IgfsClientAbstractCallable<Void> {
}
/** {@inheritDoc} */
+ @Override protected void readFrom0(MessageReader reader, int fieldId) {
+ assert fieldId == 0;
+
+ props = reader.readMap("recursive", MessageCollectionItemType.STRING, MessageCollectionItemType.STRING, false);
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientMkdirsCallable.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
index e9cc947..5f2063b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientRenameCallable.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
@@ -32,6 +33,9 @@ import org.jetbrains.annotations.Nullable;
* IGFS client rename callable.
*/
public class IgfsClientRenameCallable extends IgfsClientAbstractCallable<Void> {
+ /** Type ID. */
+ public static final short TYPE_ID = 9;
+
/** */
private static final long serialVersionUID = 0L;
@@ -53,7 +57,7 @@ public class IgfsClientRenameCallable extends IgfsClientAbstractCallable<Void> {
* @param destPath Destination path.
*/
public IgfsClientRenameCallable(@Nullable String igfsName, IgfsPath srcPath, IgfsPath destPath) {
- super(igfsName, srcPath);
+ super(TYPE_ID, igfsName, srcPath);
this.destPath = destPath;
}
@@ -88,6 +92,16 @@ public class IgfsClientRenameCallable extends IgfsClientAbstractCallable<Void> {
}
/** {@inheritDoc} */
+ @Override protected void readFrom0(MessageReader reader, int fieldId) {
+ assert fieldId == 0;
+
+ String dstPathStr = reader.readString("destPath");
+
+ if (reader.isLastRead())
+ destPath = new IgfsPath(dstPathStr);
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientRenameCallable.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
index f1beb54..2da389f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSetTimesCallable.java
@@ -23,6 +23,7 @@ import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
@@ -30,6 +31,9 @@ import org.jetbrains.annotations.Nullable;
* IGFS client set times callable.
*/
public class IgfsClientSetTimesCallable extends IgfsClientAbstractCallable<Void> {
+ /** Type ID. */
+ public static final short TYPE_ID = 10;
+
/** */
private static final long serialVersionUID = 0L;
@@ -56,7 +60,7 @@ public class IgfsClientSetTimesCallable extends IgfsClientAbstractCallable<Void>
*/
public IgfsClientSetTimesCallable(@Nullable String igfsName, IgfsPath path, long accessTime,
long modificationTime) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
this.accessTime = accessTime;
this.modificationTime = modificationTime;
@@ -100,6 +104,19 @@ public class IgfsClientSetTimesCallable extends IgfsClientAbstractCallable<Void>
}
/** {@inheritDoc} */
+ @Override protected void readFrom0(MessageReader reader, int fieldId) {
+ switch (fieldId) {
+ case 0:
+ accessTime = reader.readLong("accessTime");
+
+ default:
+ assert fieldId == 1;
+
+ modificationTime = reader.readLong("modificationTime");
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientSetTimesCallable.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
index 928d65d..a9dd7d6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSizeCallable.java
@@ -26,6 +26,9 @@ import org.jetbrains.annotations.Nullable;
* IGFS client size callable.
*/
public class IgfsClientSizeCallable extends IgfsClientAbstractCallable<Long> {
+ /** Type ID. */
+ public static final short TYPE_ID = 11;
+
/** */
private static final long serialVersionUID = 0L;
@@ -43,7 +46,7 @@ public class IgfsClientSizeCallable extends IgfsClientAbstractCallable<Long> {
* @param path Path.
*/
public IgfsClientSizeCallable(@Nullable String igfsName, IgfsPath path) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSummaryCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSummaryCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSummaryCallable.java
index 7e29029..07d4f5b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSummaryCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientSummaryCallable.java
@@ -27,6 +27,9 @@ import org.jetbrains.annotations.Nullable;
* IGFS client summary callable.
*/
public class IgfsClientSummaryCallable extends IgfsClientAbstractCallable<IgfsPathSummary> {
+ /** Type ID. */
+ public static final short TYPE_ID = 12;
+
/** */
private static final long serialVersionUID = 0L;
@@ -44,7 +47,7 @@ public class IgfsClientSummaryCallable extends IgfsClientAbstractCallable<IgfsPa
* @param path Path.
*/
public IgfsClientSummaryCallable(@Nullable String igfsName, IgfsPath path) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
index a03c7e6..db94743 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/IgfsClientUpdateCallable.java
@@ -26,6 +26,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsContext;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
@@ -35,6 +36,9 @@ import java.util.Map;
* IGFS client update callable.
*/
public class IgfsClientUpdateCallable extends IgfsClientAbstractCallable<IgfsFile> {
+ /** Type ID. */
+ public static final short TYPE_ID = 13;
+
/** */
private static final long serialVersionUID = 0L;
@@ -56,7 +60,7 @@ public class IgfsClientUpdateCallable extends IgfsClientAbstractCallable<IgfsFil
* @param props Properties.
*/
public IgfsClientUpdateCallable(@Nullable String igfsName, IgfsPath path, @Nullable Map<String, String> props) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
this.props = props;
}
@@ -89,6 +93,13 @@ public class IgfsClientUpdateCallable extends IgfsClientAbstractCallable<IgfsFil
}
/** {@inheritDoc} */
+ @Override protected void readFrom0(MessageReader reader, int fieldId) {
+ assert fieldId == 0;
+
+ props = reader.readMap("recursive", MessageCollectionItemType.STRING, MessageCollectionItemType.STRING, false);
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsClientUpdateCallable.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaIdsForPathCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaIdsForPathCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaIdsForPathCallable.java
index 7b3d142..4dbdc1a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaIdsForPathCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaIdsForPathCallable.java
@@ -31,6 +31,9 @@ import java.util.List;
* Get entry info for the given path.
*/
public class IgfsClientMetaIdsForPathCallable extends IgfsClientAbstractCallable<List<IgniteUuid>> {
+ /** Type ID. */
+ public static final short TYPE_ID = 0;
+
/** */
private static final long serialVersionUID = 0L;
@@ -48,7 +51,7 @@ public class IgfsClientMetaIdsForPathCallable extends IgfsClientAbstractCallable
* @param path Path.
*/
public IgfsClientMetaIdsForPathCallable(@Nullable String igfsName, IgfsPath path) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/bb6e87a1/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaInfoForPathCallable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaInfoForPathCallable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaInfoForPathCallable.java
index cb31663..008b2a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaInfoForPathCallable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/client/meta/IgfsClientMetaInfoForPathCallable.java
@@ -29,6 +29,9 @@ import org.jetbrains.annotations.Nullable;
* Get entry info for the given path.
*/
public class IgfsClientMetaInfoForPathCallable extends IgfsClientAbstractCallable<IgfsEntryInfo> {
+ /** Type ID. */
+ public static final short TYPE_ID = 1;
+
/** */
private static final long serialVersionUID = 0L;
@@ -46,7 +49,7 @@ public class IgfsClientMetaInfoForPathCallable extends IgfsClientAbstractCallabl
* @param path Path.
*/
public IgfsClientMetaInfoForPathCallable(@Nullable String igfsName, IgfsPath path) {
- super(igfsName, path);
+ super(TYPE_ID, igfsName, path);
}
/** {@inheritDoc} */