You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ni...@apache.org on 2020/04/04 20:18:32 UTC
[ignite] branch master updated: IGNITE-12859: Support of .Net
service call with the Timestamp and Guid params. (#7618)
This is an automated email from the ASF dual-hosted git repository.
nizhikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 2b1d2b4 IGNITE-12859: Support of .Net service call with the Timestamp and Guid params. (#7618)
2b1d2b4 is described below
commit 2b1d2b4dec2112eca8e63f96d0308a5b0c797896
Author: Nikolay <ni...@apache.org>
AuthorDate: Sat Apr 4 23:18:11 2020 +0300
IGNITE-12859: Support of .Net service call with the Timestamp and Guid params. (#7618)
---
.../processors/platform/utils/PlatformUtils.java | 2 +-
.../ignite/platform/PlatformDeployServiceTask.java | 48 ++++++++++++++++++++--
.../Services/ServicesTest.cs | 47 +++++++++++++++++++++
.../Impl/Services/ServiceProxySerializer.cs | 13 ++++++
4 files changed, 106 insertions(+), 4 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index a2f7636..2c1d0b2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.processors.platform.utils;
+import java.sql.Timestamp;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
@@ -66,7 +67,6 @@ import javax.cache.event.CacheEntryListenerException;
import javax.cache.event.EventType;
import java.lang.reflect.Field;
import java.math.BigDecimal;
-import java.security.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformDeployServiceTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformDeployServiceTask.java
index dda44c4..ca9e0bd 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformDeployServiceTask.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformDeployServiceTask.java
@@ -17,6 +17,8 @@
package org.apache.ignite.platform;
+import java.sql.Timestamp;
+import java.util.UUID;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteException;
import org.apache.ignite.binary.BinaryObject;
@@ -38,6 +40,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
+import static java.util.Calendar.JANUARY;
+
/**
* Task that deploys a Java service.
*/
@@ -177,6 +181,21 @@ public class PlatformDeployServiceTask extends ComputeTaskAdapter<String, Object
}
/** */
+ public Timestamp test(Timestamp input) {
+ Timestamp exp = new Timestamp(92, JANUARY, 1, 0, 0, 0, 0);
+
+ if (!exp.equals(input))
+ throw new RuntimeException("Expected \"" + exp + "\" but got \"" + input + "\"");
+
+ return input;
+ }
+
+ /** */
+ public UUID test(UUID input) {
+ return input;
+ }
+
+ /** */
public Byte testWrapper(Byte arg) {
return arg == null ? null : (byte) (arg + 1);
}
@@ -203,17 +222,17 @@ public class PlatformDeployServiceTask extends ComputeTaskAdapter<String, Object
/** */
public Double testWrapper(Double arg) {
- return arg == null ? null : arg + 2.5;
+ return arg == null ? null : arg + 2.5;
}
/** */
public Boolean testWrapper(Boolean arg) {
- return arg == null ? null : !arg;
+ return arg == null ? null : !arg;
}
/** */
public Character testWrapper(Character arg) {
- return arg == null ? null : (char) (arg + 1);
+ return arg == null ? null : (char) (arg + 1);
}
/** */
@@ -298,11 +317,34 @@ public class PlatformDeployServiceTask extends ComputeTaskAdapter<String, Object
}
/** */
+ public Timestamp[] testArray(Timestamp[] arg) {
+ if (arg == null || arg.length != 1)
+ throw new RuntimeException("Expected array of length 1");
+
+ return new Timestamp[] {test(arg[0])};
+ }
+
+ /** */
+ public UUID[] testArray(UUID[] arg) {
+ return arg;
+ }
+
+ /** */
public Integer testNull(Integer arg) {
return arg == null ? null : arg + 1;
}
/** */
+ public UUID testNullUUID(UUID arg) {
+ return arg;
+ }
+
+ /** */
+ public Timestamp testNullTimestamp(Timestamp arg) {
+ return arg;
+ }
+
+ /** */
public int testParams(Object... args) {
return args.length;
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
index 32a7f73..7038c84 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
@@ -870,6 +870,20 @@ namespace Apache.Ignite.Core.Tests.Services
binSvc.testBinaryObject(
Grid1.GetBinary().ToBinary<IBinaryObject>(new PlatformComputeBinarizable {Field = 6}))
.GetField<int>("Field"));
+
+ DateTime dt = new DateTime(1992, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
+
+ Assert.AreEqual(dt, svc.test(dt));
+ Assert.AreEqual(dt, svc.testNullTimestamp(dt));
+ Assert.IsNull(svc.testNullTimestamp(null));
+ Assert.AreEqual(dt, svc.testArray(new DateTime?[] {dt})[0]);
+
+ Guid guid = Guid.NewGuid();
+
+ Assert.AreEqual(guid, svc.test(guid));
+ Assert.AreEqual(guid, svc.testNullUUID(guid));
+ Assert.IsNull(svc.testNullUUID(null));
+ Assert.AreEqual(guid, svc.testArray(new Guid?[] {guid})[0]);
Services.Cancel(javaSvcName);
}
@@ -940,6 +954,20 @@ namespace Apache.Ignite.Core.Tests.Services
binSvc.testBinaryObject(
Grid1.GetBinary().ToBinary<IBinaryObject>(new PlatformComputeBinarizable { Field = 6 }))
.GetField<int>("Field"));
+
+ DateTime dt = new DateTime(1992, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
+
+ Assert.AreEqual(dt, svc.test(dt));
+ Assert.AreEqual(dt, svc.testNullTimestamp(dt));
+ Assert.IsNull(svc.testNullTimestamp(null));
+ Assert.AreEqual(dt, svc.testArray(new DateTime?[] { dt })[0]);
+
+ Guid guid = Guid.NewGuid();
+
+ Assert.AreEqual(guid, svc.test(guid));
+ Assert.AreEqual(guid, svc.testNullUUID(guid));
+ Assert.IsNull(svc.testNullUUID(null));
+ Assert.AreEqual(guid, svc.testArray(new Guid?[] { guid })[0]);
}
/// <summary>
@@ -1374,6 +1402,12 @@ namespace Apache.Ignite.Core.Tests.Services
bool test(bool x);
/** */
+ DateTime test(DateTime x);
+
+ /** */
+ Guid test(Guid x);
+
+ /** */
byte? testWrapper(byte? x);
/** */
@@ -1425,7 +1459,14 @@ namespace Apache.Ignite.Core.Tests.Services
bool[] testArray(bool[] x);
/** */
+ DateTime?[] testArray(DateTime?[] x);
+
+ /** */
+ Guid?[] testArray(Guid?[] x);
+
+ /** */
int test(int x, string y);
+
/** */
int test(string x, int y);
@@ -1433,6 +1474,12 @@ namespace Apache.Ignite.Core.Tests.Services
int? testNull(int? x);
/** */
+ DateTime? testNullTimestamp(DateTime? x);
+
+ /** */
+ Guid? testNullUUID(Guid? x);
+
+ /** */
int testParams(params object[] args);
/** */
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
index 42638bc..4817582 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
@@ -247,6 +247,16 @@ namespace Apache.Ignite.Core.Impl.Services
if (type.IsPrimitive)
return null;
+ if (type.IsArray)
+ {
+ Type elemType = type.GetElementType();
+
+ if (elemType == typeof(Guid?))
+ return (writer, o) => writer.WriteGuidArray((Guid?[]) o);
+ else if (elemType == typeof(DateTime?))
+ return (writer, o) => writer.WriteTimestampArray((DateTime?[]) o);
+ }
+
var handler = BinarySystemHandlers.GetWriteHandler(type);
if (handler != null)
@@ -258,6 +268,9 @@ namespace Apache.Ignite.Core.Impl.Services
if (arg is ICollection)
return (writer, o) => writer.WriteCollection((ICollection) o);
+ if (arg is DateTime)
+ return (writer, o) => writer.WriteTimestamp((DateTime) o);
+
return null;
}
}