/// <summary> /// Invokes the proxy. /// </summary> /// <param name="method">Method.</param> /// <param name="args">Arguments.</param> /// <returns> /// Invocation result. /// </returns> private object InvokeProxyMethod(MethodBase method, object[] args) { using (var inStream = new PlatformMemoryStream(_memory.Allocate())) using (var outStream = new PlatformMemoryStream(_memory.Allocate())) { // 1) Write to a stream inStream.WriteBool(SrvKeepBinary); // WriteProxyMethod does not do this, but Java does ServiceProxySerializer.WriteProxyMethod(_marsh.StartMarshal(inStream), method, args); inStream.SynchronizeOutput(); inStream.Seek(0, SeekOrigin.Begin); // 2) call InvokeServiceMethod string mthdName; object[] mthdArgs; ServiceProxySerializer.ReadProxyMethod(inStream, _marsh, out mthdName, out mthdArgs); var result = ServiceProxyInvoker.InvokeServiceMethod(_svc, mthdName, mthdArgs); ServiceProxySerializer.WriteInvocationResult(outStream, _marsh, result.Key, result.Value); _marsh.StartMarshal(outStream).WriteString("unused"); // fake Java exception details outStream.SynchronizeOutput(); outStream.Seek(0, SeekOrigin.Begin); return(ServiceProxySerializer.ReadInvocationResult(outStream, _marsh, KeepBinary)); } }
/// <summary> /// Invokes the proxy method. /// </summary> private object InvokeProxyMethod(string serviceName, MethodBase method, object[] args, PlatformType platformType, IDictionary callAttrs) { return(_ignite.Socket.DoOutInOp(ClientOp.ServiceInvoke, ctx => { var w = ctx.Writer; w.WriteString(serviceName); w.WriteByte(_serverKeepBinary ? (byte)ServiceFlags.KeepBinary : (byte)0); w.WriteLong((long)_timeout.TotalMilliseconds); if (_clusterGroup != null) { var nodes = _clusterGroup.GetNodes(); if (nodes.Count == 0) { throw new IgniteClientException("Cluster group is empty"); } w.WriteInt(nodes.Count); foreach (var node in nodes) { BinaryUtils.WriteGuid(node.Id, ctx.Stream); } } else { w.WriteInt(0); } w.WriteString(method.Name); ServiceProxySerializer.WriteMethodArguments(w, null, args, platformType); if (ctx.Features.HasFeature(ClientBitmaskFeature.ServiceInvokeCtx)) { w.WriteDictionary(callAttrs); } else if (callAttrs != null) { throw new IgniteClientException( "Passing caller context to the service is not supported by the server"); } }, ctx => { var reader = _keepBinary ? ctx.Marshaller.StartUnmarshal(ctx.Stream, BinaryMode.ForceBinary) : ctx.Reader; return reader.ReadObject <object>(); })); }
private long ServiceInvokeMethod(long memPtr) { using (var stream = IgniteManager.Memory.Get(memPtr).GetStream()) { var svc = _handleRegistry.Get <IService>(stream.ReadLong(), true); string mthdName; object[] mthdArgs; ServiceProxySerializer.ReadProxyMethod(stream, _ignite.Marshaller, out mthdName, out mthdArgs); var result = ServiceProxyInvoker.InvokeServiceMethod(svc, mthdName, mthdArgs); stream.Reset(); ServiceProxySerializer.WriteInvocationResult(stream, _ignite.Marshaller, result.Key, result.Value); stream.SynchronizeOutput(); return(0); } }
private void ServiceInvokeMethod(void *target, long svcPtr, long inMemPtr, long outMemPtr) { SafeCall(() => { using (var inStream = IgniteManager.Memory.Get(inMemPtr).GetStream()) using (var outStream = IgniteManager.Memory.Get(outMemPtr).GetStream()) { var svc = _handleRegistry.Get <IService>(svcPtr, true); string mthdName; object[] mthdArgs; ServiceProxySerializer.ReadProxyMethod(inStream, _ignite.Marshaller, out mthdName, out mthdArgs); var result = ServiceProxyInvoker.InvokeServiceMethod(svc, mthdName, mthdArgs); ServiceProxySerializer.WriteInvocationResult(outStream, _ignite.Marshaller, result.Key, result.Value); outStream.SynchronizeOutput(); } }); }