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 1d226af103f1a..71934e9d76314 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 @@ -54,10 +54,14 @@ import org.apache.ignite.platform.model.Parameter; import org.apache.ignite.platform.model.Role; import org.apache.ignite.platform.model.User; +import org.apache.ignite.platform.model.V10; +import org.apache.ignite.platform.model.V11; +import org.apache.ignite.platform.model.V12; import org.apache.ignite.platform.model.V5; import org.apache.ignite.platform.model.V6; import org.apache.ignite.platform.model.V7; import org.apache.ignite.platform.model.V8; +import org.apache.ignite.platform.model.V9; import org.apache.ignite.platform.model.Value; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.services.Service; @@ -651,6 +655,23 @@ public void testLocalDateFromCache() { cache.put(8, ts2); } + /** */ + public void putValsForCache() { + ignite.getOrCreateCache("V9").put(1, new V9("1")); + + IgniteCache v10 = ignite.getOrCreateCache("V10"); + + v10.put(1, new V10("1")); + v10.put(2, new V10("2")); + + ignite.getOrCreateCache("V11").put(1, new V11("1")); + + IgniteCache v12 = ignite.getOrCreateCache("V12"); + + v12.put(1, new V12("1")); + v12.put(2, new V12("2")); + } + /** */ private final AtomicInteger cntMsgs = new AtomicInteger(0); diff --git a/modules/core/src/test/java/org/apache/ignite/platform/model/V10.java b/modules/core/src/test/java/org/apache/ignite/platform/model/V10.java new file mode 100644 index 0000000000000..4cdac5725e3ba --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/platform/model/V10.java @@ -0,0 +1,34 @@ +/* + * 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.platform.model; + +/** Test V10 object. */ +public class V10 { + /** */ + private final String name; + + /** */ + public V10(String name) { + this.name = name; + } + + /** */ + public String getName() { + return name; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/platform/model/V11.java b/modules/core/src/test/java/org/apache/ignite/platform/model/V11.java new file mode 100644 index 0000000000000..b1e880ba0cbbc --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/platform/model/V11.java @@ -0,0 +1,34 @@ +/* + * 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.platform.model; + +/** Test V11 object. */ +public class V11 { + /** */ + private final String name; + + /** */ + public V11(String name) { + this.name = name; + } + + /** */ + public String getName() { + return name; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/platform/model/V12.java b/modules/core/src/test/java/org/apache/ignite/platform/model/V12.java new file mode 100644 index 0000000000000..a0b6a0cbd6a62 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/platform/model/V12.java @@ -0,0 +1,34 @@ +/* + * 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.platform.model; + +/** Test V12 object. */ +public class V12 { + /** */ + private final String name; + + /** */ + public V12(String name) { + this.name = name; + } + + /** */ + public String getName() { + return name; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/platform/model/V9.java b/modules/core/src/test/java/org/apache/ignite/platform/model/V9.java new file mode 100644 index 0000000000000..67f856235eb82 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/platform/model/V9.java @@ -0,0 +1,34 @@ +/* + * 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.platform.model; + +/** Test V9 object. */ +public class V9 { + /** */ + private final String name; + + /** */ + public V9(String name) { + this.name = name; + } + + /** */ + public String getName() { + return name; + } +} diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/IJavaService.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/IJavaService.cs index db1b546a9a6fe..895a30f9066a5 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/IJavaService.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/IJavaService.cs @@ -213,6 +213,9 @@ public interface IJavaService /** */ void sleep(long delayMs); + /** */ + void putValsForCache(); + /** */ void startReceiveMessage(); diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/JavaServiceDynamicProxy.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/JavaServiceDynamicProxy.cs index b872b3c0ffdf0..02e110bf736fd 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/JavaServiceDynamicProxy.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/JavaServiceDynamicProxy.cs @@ -413,6 +413,12 @@ public void testSendMessage() _svc.testSendMessage(); } + /** */ + public void putValsForCache() + { + _svc.putValsForCache(); + } + /** */ public object testRoundtrip(object x) { diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/Model.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/Model.cs index b0b9645bc0957..b1f350caa531a 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/Model.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/Model.cs @@ -212,12 +212,32 @@ public class V5 { public String Name { get; set; } } public class V6 { public String Name { get; set; } } /// - /// A class is a clone of Java class V6 with the same namespace. + /// A class is a clone of Java class V7 with the same namespace. /// public class V7 { public String Name { get; set; } } /// - /// A class is a clone of Java class V6 with the same namespace. + /// A class is a clone of Java class V8 with the same namespace. /// public class V8 { public String Name { get; set; } } + + /// + /// A class is a clone of Java class V9 with the same namespace. + /// + public class V9 { public String Name { get; set; } } + + /// + /// A class is a clone of Java class V10 with the same namespace. + /// + public class V10 { public String Name { get; set; } } + + /// + /// A class is a clone of Java class V11 with the same namespace. + /// + public class V11 { public String Name { get; set; } } + + /// + /// A class is a clone of Java class V12 with the same namespace. + /// + public class V12 { public String Name { get; set; } } } diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/PlatformTestService.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/PlatformTestService.cs index f5a6d62c64c54..e6276ed3e3d30 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/PlatformTestService.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/PlatformTestService.cs @@ -638,6 +638,23 @@ public void testSendMessage() throw new NotImplementedException(); } + public void putValsForCache() + { + _ignite.GetOrCreateCache("V9").Put(1, new V9 {Name = "1"}); + + var v10 = _ignite.GetOrCreateCache("V10"); + + v10.Put(1, new V10 {Name = "1"}); + v10.Put(2, new V10 {Name = "2"}); + + _ignite.GetOrCreateCache("V11").Put(1, new V11 {Name = "1"}); + + var v12 = _ignite.GetOrCreateCache("V12"); + + v12.Put(1, new V12 {Name = "1"}); + v12.Put(2, new V12 {Name = "2"}); + } + /** */ public object testRoundtrip(object x) { diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs index c22d2cbab6527..f2803c4bc426b 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs @@ -287,6 +287,36 @@ private void DoTestService(IJavaService svc, bool isPlatform = false) if (_useBinaryArray) Assert.AreEqual(typeof(User[]), users2.GetType()); + + svc.putValsForCache(); + + Assert.AreEqual("1", _grid1.GetCache("V9").Get(1).Name); + + var v10 = _grid1.GetCache("V10").GetAll(new List {1, 2}); + + Assert.AreEqual(2, v10.Count); + + foreach (var entry in v10) + { + if (entry.Key == 1) + Assert.AreEqual("1", entry.Value.Name); + else + Assert.AreEqual("2", entry.Value.Name); + } + + Assert.AreEqual("1", _grid1.GetCache("V11").GetAsync(1).Result.Name); + + var v12 = _grid1.GetCache("V12").GetAllAsync(new List {1, 2}).Result; + + Assert.AreEqual(2, v12.Count); + + foreach (var entry in v12) + { + if (entry.Key == 1) + Assert.AreEqual("1", entry.Value.Name); + else + Assert.AreEqual("2", entry.Value.Name); + } } /// diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs index b62faabd5d77f..325fec3a89d87 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs @@ -142,7 +142,7 @@ private bool CanUsePlatformCache /// private Task DoOutOpAsync(CacheOp op, T1 val1) { - return DoOutOpAsync((int) op, val1); + return DoOutOpAsync((int) op, val1, IsKeepBinary); } /// @@ -150,7 +150,7 @@ private Task DoOutOpAsync(CacheOp op, T1 val1) /// private Task DoOutOpAsync(CacheOp op, T1 val1) { - return DoOutOpAsync((int) op, val1); + return DoOutOpAsync((int) op, val1, IsKeepBinary); } /// @@ -158,7 +158,7 @@ private Task DoOutOpAsync(CacheOp op, T1 val1) /// private Task DoOutOpAsync(CacheOp op, T1 val1, T2 val2) { - return DoOutOpAsync((int) op, val1, val2); + return DoOutOpAsync((int) op, val1, val2, IsKeepBinary); } /// @@ -166,7 +166,7 @@ private Task DoOutOpAsync(CacheOp op, T1 val1, T2 val2) /// private Task DoOutOpAsync(CacheOp op, T1 val1, T2 val2) { - return DoOutOpAsync((int) op, val1, val2); + return DoOutOpAsync((int) op, val1, val2, IsKeepBinary); } /// @@ -197,7 +197,7 @@ public string Name public CacheConfiguration GetConfiguration() { return DoInOp((int) CacheOp.GetConfig, stream => new CacheConfiguration( - BinaryUtils.Marshaller.StartUnmarshal(stream))); + BinaryUtils.Marshaller.StartUnmarshal(stream)), IsKeepBinary); } /** */ @@ -270,7 +270,7 @@ public ICache WithExpiryPolicy(IExpiryPolicy plc) { IgniteArgumentCheck.NotNull(plc, "plc"); - var cache0 = DoOutOpObject((int)CacheOp.WithExpiryPolicy, w => ExpiryPolicySerializer.WritePolicy(w, plc)); + var cache0 = DoOutOpObject((int)CacheOp.WithExpiryPolicy, w => ExpiryPolicySerializer.WritePolicy(w, plc), IsKeepBinary); return new CacheImpl( cache0, @@ -295,7 +295,7 @@ public bool IsAllowAtomicOpsInTx /** */ public void LoadCache(ICacheEntryFilter p, params object[] args) { - DoOutInOpX((int) CacheOp.LoadCache, writer => WriteLoadCacheData(writer, p, args), _readException); + DoOutInOpX((int) CacheOp.LoadCache, writer => WriteLoadCacheData(writer, p, args), _readException, IsKeepBinary); } /** */ @@ -307,7 +307,7 @@ public Task LoadCacheAsync(ICacheEntryFilter p, params object[] args) /** */ public void LocalLoadCache(ICacheEntryFilter p, params object[] args) { - DoOutInOpX((int) CacheOp.LocLoadCache, writer => WriteLoadCacheData(writer, p, args), _readException); + DoOutInOpX((int) CacheOp.LocLoadCache, writer => WriteLoadCacheData(writer, p, args), _readException, IsKeepBinary); } /** */ @@ -511,7 +511,7 @@ public bool TryLocalPeek(TK key, out TV value, params CachePeekMode[] modes) w.WriteInt(peekModes); }, (s, r) => r == True ? new CacheResult(Unmarshal(s)) : new CacheResult(), - _readException); + _readException, IsKeepBinary); value = res.Success ? res.Value : default(TV); @@ -552,7 +552,7 @@ public TV Get(TK key) throw GetKeyNotFoundException(key); return Unmarshal(stream); - }, _readException); + }, _readException, IsKeepBinary); } /** */ @@ -657,7 +657,7 @@ public ICollection> GetAll(IEnumerable keys) (s, r) => r == True ? ReadGetAllDictionary(Marshaller.StartUnmarshal(s, _flagKeepBinary), res) : res, - _readException); + _readException, IsKeepBinary); // ReSharper restore AccessToDisposedClosure } } @@ -667,7 +667,7 @@ public ICollection> GetAll(IEnumerable keys) (s, r) => r == True ? ReadGetAllDictionary(Marshaller.StartUnmarshal(s, _flagKeepBinary)) : null, - _readException); + _readException, IsKeepBinary); } /** */ @@ -1209,7 +1209,7 @@ private long Size0(bool loc, int? part, params CachePeekMode[] modes) { writer.WriteBoolean(false); } - }) + platformCacheSize; + }, IsKeepBinary) + platformCacheSize; } /// @@ -1315,7 +1315,7 @@ public TRes Invoke(TK key, ICacheEntryProcessor writer.WriteObjectDetached(holder); }, (input, res) => res == True ? Unmarshal(input) : default(TRes), - _readException); + _readException, IsKeepBinary); } finally { @@ -1395,7 +1395,7 @@ public ICollection> InvokeAll(I }, (input, res) => res == True ? ReadInvokeAllResults(Marshaller.StartUnmarshal(input, IsKeepBinary)) - : null, _readException); + : null, _readException, IsKeepBinary); } finally { @@ -1456,7 +1456,7 @@ public T DoOutInOpExtension(int extensionId, int opCode, Action res == True ? readFunc(Marshaller.StartUnmarshal(input)) - : default(T), _readException); + : default(T), _readException, IsKeepBinary); } /** */ @@ -1465,7 +1465,7 @@ public ICacheLock Lock(TK key) IgniteArgumentCheck.NotNull(key, "key"); return DoOutInOpX((int) CacheOp.Lock, w => w.Write(key), - (stream, res) => new CacheLock(stream.ReadInt(), this), _readException); + (stream, res) => new CacheLock(stream.ReadInt(), this), _readException, IsKeepBinary); } /** */ @@ -1474,7 +1474,7 @@ public ICacheLock LockAll(IEnumerable keys) IgniteArgumentCheck.NotNull(keys, "keys"); return DoOutInOpX((int) CacheOp.LockAll, w => w.WriteEnumerable(keys), - (stream, res) => new CacheLock(stream.ReadInt(), this), _readException); + (stream, res) => new CacheLock(stream.ReadInt(), this), _readException, IsKeepBinary); } /** */ @@ -1497,7 +1497,7 @@ public ICacheMetrics GetMetrics() IBinaryRawReader reader = Marshaller.StartUnmarshal(stream, false); return new CacheMetricsImpl(reader); - }); + }, IsKeepBinary); } /** */ @@ -1521,7 +1521,7 @@ public ICacheMetrics GetLocalMetrics() IBinaryRawReader reader = Marshaller.StartUnmarshal(stream, false); return new CacheMetricsImpl(reader); - }); + }, IsKeepBinary); } /** */ @@ -1592,7 +1592,7 @@ public ICollection GetLostPartitions() } return res; - }); + }, IsKeepBinary); } #region Queries @@ -1639,7 +1639,7 @@ public IQueryCursor> Query(QueryBase qry) } } - var cursor = DoOutOpObject((int) qry.OpId, writer => qry.Write(writer, IsKeepBinary)); + var cursor = DoOutOpObject((int) qry.OpId, writer => qry.Write(writer, IsKeepBinary), IsKeepBinary); return new QueryCursor(cursor, _flagKeepBinary); } @@ -1667,7 +1667,7 @@ public IContinuousQueryHandleFields QueryContinuous(ContinuousQuery qry, qry.Validate(); return new ContinuousQueryHandleImpl(qry, Marshaller, _flagKeepBinary, - writeAction => DoOutOpObject((int) CacheOp.QryContinuous, writeAction), initialQry); + writeAction => DoOutOpObject((int) CacheOp.QryContinuous, writeAction, IsKeepBinary), initialQry); } /// @@ -1679,7 +1679,7 @@ private IContinuousQueryHandle> QueryContinuousImpl(Continuo qry.Validate(); return new ContinuousQueryHandleImpl(qry, Marshaller, _flagKeepBinary, - writeAction => DoOutOpObject((int) CacheOp.QryContinuous, writeAction), initialQry); + writeAction => DoOutOpObject((int) CacheOp.QryContinuous, writeAction, IsKeepBinary), initialQry); } #endregion @@ -1734,7 +1734,7 @@ internal CacheEnumerator CreateEnumerator(bool loc, int peekModes) { if (loc) { - var target = DoOutOpObject((int) CacheOp.LocIterator, (IBinaryStream s) => s.WriteInt(peekModes)); + var target = DoOutOpObject((int) CacheOp.LocIterator, (IBinaryStream s) => s.WriteInt(peekModes), IsKeepBinary); return new CacheEnumerator(target, _flagKeepBinary); } @@ -1861,7 +1861,7 @@ private bool DoOutOp(CacheOp op, T1 x) return DoOutInOpX((int) op, w => { w.Write(x); - }, _readException); + }, _readException, IsKeepBinary); } /// @@ -1873,7 +1873,7 @@ private bool DoOutOp(CacheOp op, T1 x, T2 y) { w.WriteObjectDetached(x); w.WriteObjectDetached(y); - }, _readException); + }, _readException, IsKeepBinary); } /// @@ -1886,7 +1886,7 @@ private bool DoOutOp(CacheOp op, T1 x, T2 y, T3 z) w.WriteObjectDetached(x); w.WriteObjectDetached(y); w.WriteObjectDetached(z); - }, _readException); + }, _readException, IsKeepBinary); } /// @@ -1894,7 +1894,7 @@ private bool DoOutOp(CacheOp op, T1 x, T2 y, T3 z) /// private bool DoOutOp(CacheOp op, Action write) { - return DoOutInOpX((int) op, write, _readException); + return DoOutInOpX((int) op, write, _readException, IsKeepBinary); } /// @@ -1905,7 +1905,7 @@ private CacheResult DoOutInOpNullable(CacheOp cacheOp, TK x) return DoOutInOpX((int)cacheOp, w => w.Write(x), (stream, res) => res == True ? new CacheResult(Unmarshal(stream)) : new CacheResult(), - _readException); + _readException, IsKeepBinary); } /// @@ -1920,7 +1920,7 @@ private CacheResult DoOutInOpNullable(CacheOp cacheOp, T1 x, T2 y) w.WriteObjectDetached(y); }, (stream, res) => res == True ? new CacheResult(Unmarshal(stream)) : new CacheResult(), - _readException); + _readException, IsKeepBinary); } /** */ @@ -1936,7 +1936,7 @@ public bool TryEnter(long id, TimeSpan timeout) { s.WriteLong(id); s.WriteLong((long) timeout.TotalMilliseconds); - }) == True; + }, IsKeepBinary) == True; } /** */ @@ -1959,7 +1959,7 @@ public IQueryMetrics GetQueryMetrics() IBinaryRawReader reader = Marshaller.StartUnmarshal(stream, false); return new QueryMetricsImpl(reader); - }); + }, IsKeepBinary); } /** */ @@ -2109,7 +2109,7 @@ private IPlatformTargetInternal QueryFieldsInternal(SqlFieldsQuery qry) if (string.IsNullOrEmpty(qry.Sql)) throw new ArgumentException("Sql cannot be null or empty"); - return DoOutOpObject((int) CacheOp.QrySqlFields, writer => qry.Write(writer)); + return DoOutOpObject((int) CacheOp.QrySqlFields, writer => qry.Write(writer), IsKeepBinary); } } } diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs index 153775c4f1ba6..ac85e5332dfa6 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs @@ -159,7 +159,7 @@ public void WithKeepBinary() /// New instance associated with a specified executor. public ComputeImpl WithExecutor(string executorName) { - var target = DoOutOpObject(OpWithExecutor, w => w.WriteString(executorName)); + var target = DoOutOpObject(OpWithExecutor, w => w.WriteString(executorName), _keepBinary.Value); return new ComputeImpl(target, _prj, _keepBinary.Value); } @@ -180,7 +180,7 @@ public TReduceRes ExecuteJavaTask(string taskName, object taskArg) try { - return DoOutInOp(OpExec, writer => WriteTask(writer, taskName, taskArg, nodes)); + return DoOutInOp(OpExec, writer => WriteTask(writer, taskName, taskArg, nodes), _keepBinary.Value); } finally { @@ -206,7 +206,7 @@ public Future ExecuteJavaTaskAsync(string taskName, obje try { - return DoOutOpObjectAsync(OpExecAsync, w => WriteTask(w, taskName, taskArg, nodes)); + return DoOutOpObjectAsync(OpExecAsync, w => WriteTask(w, taskName, taskArg, nodes), _keepBinary.Value); } finally { @@ -235,7 +235,7 @@ public Future Execute(IComputeTask DoAffinityOp(object cacheNames, int? partition, w.WriteWithPeerDeployment(func); w.WriteLong(handle); - }); + }, _keepBinary.Value); fut.Task.ContWith(_ => handleRegistry.Release(handle), TaskContinuationOptions.ExecuteSynchronously); @@ -653,7 +653,7 @@ private Future ExecuteClosures0( if (writeAction != null) writeAction(writer); - }); + }, _keepBinary.Value); holder.Future.SetTarget(new Listenable(futTarget)); } diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTargetAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTargetAdapter.cs index d56656ec0aac2..92b4ea68ab81d 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTargetAdapter.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTargetAdapter.cs @@ -93,15 +93,41 @@ public Marshaller Marshaller #region OUT operations + /// + /// Enables Register Same Java Type mode is keepBinary = false. + /// + /// Action. + /// Keep binary flag. + /// + private static T WithReg(Func action, bool keepBinary) + { + if (keepBinary) + return action.Invoke(); + + bool locRegisterSameJavaType = Marshaller.RegisterSameJavaTypeTl.Value; + + Marshaller.RegisterSameJavaTypeTl.Value = true; + + try + { + return action.Invoke(); + } + finally + { + Marshaller.RegisterSameJavaTypeTl.Value = locRegisterSameJavaType; + } + } + /// /// Perform out operation. /// /// Operation type. /// Action to be performed on the stream. + /// Keep binary flag. /// - protected long DoOutOp(int type, Action action) + protected long DoOutOp(int type, Action action, bool keepBinary = false) { - return _target.InStreamOutLong(type, action); + return WithReg(() => _target.InStreamOutLong(type, action), keepBinary); } /// @@ -109,10 +135,11 @@ protected long DoOutOp(int type, Action action) /// /// Operation type. /// Action to be performed on the stream. + /// Keep binary flag. /// - protected long DoOutOp(int type, Action action) + protected long DoOutOp(int type, Action action, bool keepBinary = false) { - return DoOutOp(type, stream => WriteToStream(action, stream, _marsh)); + return DoOutOp(type, stream => WriteToStream(action, stream, _marsh), keepBinary); } /// @@ -120,10 +147,11 @@ protected long DoOutOp(int type, Action action) /// /// Operation type. /// Action to be performed on the stream. + /// Keep binary flag. /// Resulting object. - protected IPlatformTargetInternal DoOutOpObject(int type, Action action) + protected IPlatformTargetInternal DoOutOpObject(int type, Action action, bool keepBinary = false) { - return _target.InStreamOutObject(type, stream => WriteToStream(action, stream, _marsh)); + return WithReg(() => _target.InStreamOutObject(type, stream => WriteToStream(action, stream, _marsh)), keepBinary); } /// @@ -131,10 +159,11 @@ protected IPlatformTargetInternal DoOutOpObject(int type, Action a /// /// Operation type. /// Action to be performed on the stream. + /// Keep binary flag. /// Resulting object. - protected IPlatformTargetInternal DoOutOpObject(int type, Action action) + protected IPlatformTargetInternal DoOutOpObject(int type, Action action, bool keepBinary = false) { - return _target.InStreamOutObject(type, action); + return WithReg(() => _target.InStreamOutObject(type, action), keepBinary); } /// @@ -152,13 +181,14 @@ protected IPlatformTargetInternal DoOutOpObject(int type) /// /// Operation type. /// Value. + /// Keep binary flag. /// Result. - protected long DoOutOp(int type, T1 val1) + protected long DoOutOp(int type, T1 val1, bool keepBinary = false) { return DoOutOp(type, writer => { writer.Write(val1); - }); + }, keepBinary); } /// @@ -167,14 +197,15 @@ protected long DoOutOp(int type, T1 val1) /// Operation type. /// Value 1. /// Value 2. + /// Keep binary flag. /// Result. - protected long DoOutOp(int type, T1 val1, T2 val2) + protected long DoOutOp(int type, T1 val1, T2 val2, bool keepBinary = false) { return DoOutOp(type, writer => { writer.Write(val1); writer.Write(val2); - }); + }, keepBinary); } #endregion @@ -186,10 +217,11 @@ protected long DoOutOp(int type, T1 val1, T2 val2) /// /// Type. /// Action. + /// Keep binary flag. /// Result. - protected T DoInOp(int type, Func action) + protected T DoInOp(int type, Func action, bool keepBinary = false) { - return _target.OutStream(type, action); + return WithReg(() => _target.OutStream(type, action), keepBinary); } /// @@ -213,10 +245,11 @@ protected T DoInOp(int type) /// Out action. /// In action. /// Error action. + /// Keep binary flag. /// Result. - protected TR DoOutInOp(int type, Action outAction, Func inAction, Func errorAction = null) + protected TR DoOutInOp(int type, Action outAction, Func inAction, Func errorAction = null, bool keepBinary = false) { - return _target.InStreamOutStream(type, stream => WriteToStream(outAction, stream, _marsh), inAction, errorAction); + return WithReg(() => _target.InStreamOutStream(type, stream => WriteToStream(outAction, stream, _marsh), inAction, errorAction), keepBinary); } /// @@ -227,14 +260,15 @@ protected TR DoOutInOp(int type, Action outAction, FuncOut action. /// In action. /// The action to read an error. + /// Keep binary flag. /// /// Result. /// protected TR DoOutInOpX(int type, Action outAction, Func inAction, - Func inErrorAction) + Func inErrorAction, bool keepBinary = false) { - return _target.InStreamOutLong(type, stream => WriteToStream(outAction, stream, _marsh), - inAction, inErrorAction); + return WithReg(() => _target.InStreamOutLong(type, stream => WriteToStream(outAction, stream, _marsh), + inAction, inErrorAction), keepBinary); } /// @@ -243,14 +277,15 @@ protected TR DoOutInOpX(int type, Action outAction, FuncOperation type. /// Out action. /// The action to read an error. + /// Keep binary flag. /// /// Result. /// protected bool DoOutInOpX(int type, Action outAction, - Func inErrorAction) + Func inErrorAction, bool keepBinary = false) { - return _target.InStreamOutLong(type, stream => WriteToStream(outAction, stream, _marsh), - (stream, res) => res == True, inErrorAction); + return WithReg(() => _target.InStreamOutLong(type, stream => WriteToStream(outAction, stream, _marsh), + (stream, res) => res == True, inErrorAction), keepBinary); } /// @@ -260,12 +295,13 @@ protected bool DoOutInOpX(int type, Action outAction, /// Out action. /// In action. /// Argument. + /// Keep binary flag. /// Result. protected TR DoOutInOp(int type, Action outAction, - Func inAction, IPlatformTargetInternal arg) + Func inAction, IPlatformTargetInternal arg, bool keepBinary = false) { - return _target.InObjectStreamOutObjectStream(type, stream => WriteToStream(outAction, stream, _marsh), - inAction, arg); + return WithReg(() => _target.InObjectStreamOutObjectStream(type, stream => WriteToStream(outAction, stream, _marsh), + inAction, arg), keepBinary); } /// @@ -273,11 +309,12 @@ protected TR DoOutInOp(int type, Action outAction, /// /// Operation type. /// Out action. + /// Keep binary flag. /// Result. - protected TR DoOutInOp(int type, Action outAction) + protected TR DoOutInOp(int type, Action outAction, bool keepBinary = false) { - return _target.InStreamOutStream(type, stream => WriteToStream(outAction, stream, _marsh), - stream => Unmarshal(stream)); + return WithReg(() => _target.InStreamOutStream(type, stream => WriteToStream(outAction, stream, _marsh), + stream => Unmarshal(stream)), keepBinary); } /// @@ -285,11 +322,12 @@ protected TR DoOutInOp(int type, Action outAction) /// /// Operation type. /// Value. + /// Keep binary flag. /// Result. - protected TR DoOutInOp(int type, T1 val) + protected TR DoOutInOp(int type, T1 val, bool keepBinary = false) { - return _target.InStreamOutStream(type, stream => WriteToStream(val, stream, _marsh), - stream => Unmarshal(stream)); + return WithReg(() => _target.InStreamOutStream(type, stream => WriteToStream(val, stream, _marsh), + stream => Unmarshal(stream)), keepBinary); } /// @@ -312,10 +350,11 @@ protected long DoOutInOp(int type, long val = 0) /// /// The type code. /// The write action. + /// Keep binary flag. /// Task for async operation - protected Task DoOutOpAsync(int type, Action writeAction = null) + protected Task DoOutOpAsync(int type, Action writeAction = null, bool keepBinary = false) { - return DoOutOpAsync(type, writeAction); + return DoOutOpAsync(type, writeAction, keepBinary); } /// @@ -338,7 +377,7 @@ protected Task DoOutOpAsync(int type, Action writeAction = n } w.WriteLong(futId); w.WriteInt(futType); - }), keepBinary, convertFunc).Task; + }, keepBinary), keepBinary, convertFunc).Task; } /// @@ -347,15 +386,16 @@ protected Task DoOutOpAsync(int type, Action writeAction = n /// Type of the result. /// The type code. /// The write action. + /// Keep binary flag. /// Future for async operation - protected Future DoOutOpObjectAsync(int type, Action writeAction) + protected Future DoOutOpObjectAsync(int type, Action writeAction, bool keepBinary = false) { return GetFuture((futId, futType) => DoOutOpObject(type, w => { writeAction(w); w.WriteLong(futId); w.WriteInt(futType); - })); + }, keepBinary), keepBinary); } /// @@ -365,17 +405,18 @@ protected Future DoOutOpObjectAsync(int type, Action writeAc /// The type of the first arg. /// The type code. /// First arg. + /// Keep binary flag. /// /// Task for async operation /// - protected Task DoOutOpAsync(int type, T1 val1) + protected Task DoOutOpAsync(int type, T1 val1, bool keepBinary = false) { return GetFuture((futId, futType) => DoOutOp(type, w => { w.WriteObject(val1); w.WriteLong(futId); w.WriteInt(futType); - })).Task; + }, keepBinary), keepBinary).Task; } /// @@ -387,10 +428,11 @@ protected Task DoOutOpAsync(int type, T1 val1) /// The type code. /// First arg. /// Second arg. + /// Keep binary flag. /// /// Task for async operation /// - protected Task DoOutOpAsync(int type, T1 val1, T2 val2) + protected Task DoOutOpAsync(int type, T1 val1, T2 val2, bool keepBinary = false) { return GetFuture((futId, futType) => DoOutOp(type, w => { @@ -398,7 +440,7 @@ protected Task DoOutOpAsync(int type, T1 val1, T2 val2) w.WriteObjectDetached(val2); w.WriteLong(futId); w.WriteInt(futType); - })).Task; + }, keepBinary), keepBinary).Task; } #endregion @@ -468,31 +510,33 @@ private Future GetFuture(Func listenAc private Future GetFuture(Action listenAction, bool keepBinary = false, Func convertFunc = null) { - var futType = FutureType.Object; + return WithReg(() => { + var futType = FutureType.Object; - var type = typeof(T); + var type = typeof(T); - if (type.IsPrimitive) - IgniteFutureTypeMap.TryGetValue(type, out futType); + if (type.IsPrimitive) + IgniteFutureTypeMap.TryGetValue(type, out futType); - var fut = convertFunc == null && futType != FutureType.Object - ? new Future() - : new Future(new FutureConverter(_marsh, keepBinary, convertFunc)); + var fut = convertFunc == null && futType != FutureType.Object + ? new Future() + : new Future(new FutureConverter(_marsh, keepBinary, convertFunc)); - var futHnd = _marsh.Ignite.HandleRegistry.Allocate(fut); + var futHnd = _marsh.Ignite.HandleRegistry.Allocate(fut); - try - { - listenAction(futHnd, (int)futType); - } - catch (Exception) - { - _marsh.Ignite.HandleRegistry.Release(futHnd); + try + { + listenAction(futHnd, (int)futType); + } + catch (Exception) + { + _marsh.Ignite.HandleRegistry.Release(futHnd); - throw; - } + throw; + } - return fut; + return fut; + }, keepBinary); } ///