public override bool Contains(long cellId)
        {
            TrinityMessage   request;
            TrinityResponse  response;
            TrinityErrorCode eResult;
            bool             contains = false;

            request = new TrinityMessage(TrinityMessageType.PRESERVED_SYNC_WITH_RSP, (ushort)RequestType.Contains, sizeof(long));
            *(long *)(request.Buffer + TrinityMessage.Offset) = cellId;
            Network.Client.SynClient sc = GetClient();
            eResult = sc.SendMessage(request.Buffer, request.Size, out response);
            PutBackClient(sc);

            if (eResult == TrinityErrorCode.E_SUCCESS)
            {
                //returns E_CELL_FOUND or E_CELL_NOTFOUND
                contains = (response.ErrorCode == TrinityErrorCode.E_CELL_FOUND);
            }

            request.Dispose();
            response.Dispose();

            _error_check(eResult);
            return(contains);
        }
        public override TrinityErrorCode LoadCell(long cellId, out byte[] cellBuff, out ushort cellType)
        {
            TrinityMessage msg = new TrinityMessage(TrinityMessageType.PRESERVED_SYNC_WITH_RSP, (ushort)RequestType.LoadCellWithType, sizeof(long));

            *(long *)(msg.Buffer + TrinityMessage.Offset) = cellId;

            TrinityResponse response;

            Network.Client.SynClient sc = GetClient();
            bool sendSuccess            = (TrinityErrorCode.E_SUCCESS == sc.SendMessage(msg.Buffer, msg.Size, out response));

            PutBackClient(sc);
            msg.Dispose();

            int   payload_len = response.Size - response.Offset;
            byte *payload_ptr = response.Buffer + response.Offset;
            int   cell_len    = payload_len - sizeof(ushort);

            cellBuff = new byte[cell_len];
            var eResult = response.ErrorCode;

            Memory.Copy(payload_ptr, 0, cellBuff, 0, cell_len);
            cellType = *(ushort *)(payload_ptr + cell_len);
            response.Dispose();
            return(sendSuccess ? eResult : TrinityErrorCode.E_NETWORK_SEND_FAILURE);
        }
Beispiel #3
0
        private unsafe void RedirectMessageWithResponse_impl(SynReqRspArgs args)
        {
            /******************************
            * Protocol: RedirectMessage
            * Request: |4B PartitionId| TrinityMessage |
            * Response: | TrinityResponse |
            *
            * Redirects the message to another instance.
            ******************************/

            PointerHelper sp          = PointerHelper.New(args.Buffer + args.Offset);
            int           partitionId = *sp.ip++;

            TrinityMessage tm = new TrinityMessage(sp.bp, (*sp.ip) + TrinityProtocol.SocketMsgHeader);

            m_memorycloud[partitionId].SendMessage(tm, out var rsp);

            int   rsp_size = TrinityProtocol.MsgHeader + rsp.Size;
            byte *rsp_buf  = (byte *)Memory.malloc((ulong)rsp_size);

            *(int *)rsp_buf = rsp_size - TrinityProtocol.SocketMsgHeader;
            Memory.Copy(rsp.Buffer, rsp.Offset, rsp_buf, TrinityProtocol.MsgHeader, rsp.Size);
            rsp.Dispose();

            args.Response = new TrinityMessage(rsp_buf, rsp_size);
        }
Beispiel #4
0
        internal bool GetCommunicationModuleOffset(string moduleName, out ushort synReqOffset, out ushort synReqRspOffset, out ushort asynReqOffset)
        {
            /******************
            * Comm. protocol:
            *  - REQUEST : [char_cnt, char[] moduleName]
            *  - RESPONSE: [int synReqOffset, int synReqRspOffset, int asynReqOffset]
            * An response error code other than E_SUCCESS indicates failure of remote module lookup.
            ******************/

            using (TrinityMessage tm = new TrinityMessage(
                       TrinityMessageType.PRESERVED_SYNC_WITH_RSP,
                       (ushort)RequestType.GetCommunicationModuleOffsets,
                       size: sizeof(int) + sizeof(char) * moduleName.Length))
            {
                SmartPointer sp = SmartPointer.New(tm.Buffer + TrinityMessage.Offset);
                *sp.ip++        = moduleName.Length;

                BitHelper.WriteString(moduleName, sp.bp);
                TrinityResponse response;
                this.SendMessage(tm, out response);

                sp.bp = response.Buffer + response.Offset;
                int synReq_msg    = *sp.ip++;
                int synReqRsp_msg = *sp.ip++;
                int asynReq_msg   = *sp.ip++;

                synReqOffset    = (ushort)synReq_msg;
                synReqRspOffset = (ushort)synReqRsp_msg;
                asynReqOffset   = (ushort)asynReq_msg;

                return(response.ErrorCode == TrinityErrorCode.E_SUCCESS);
            }
        }
Beispiel #5
0
        public TrinityErrorCode UpdateCell(long cellId, byte *cellPtr, int length)
        {
            TrinityMessage msg = new TrinityMessage(TrinityMessageType.PRESERVED_SYNC_WITH_RSP, (ushort)RequestType.UpdateCell, length + 12 /*cell_id(8) +cell_size(4)*/);
            byte *         p   = msg.Buffer + TrinityMessage.Offset;

            *(long *)p = cellId;
            p         += 8;

            *(int *)p = length;
            p        += 4;

            Memory.Copy(cellPtr, p, length);

            TrinityResponse response;

            Network.Client.SynClient sc = GetClient();
            bool sendSuccess            = (TrinityErrorCode.E_SUCCESS == sc.SendMessage(msg.Buffer, msg.Size, out response));

            PutBackClient(sc);
            msg.Dispose();

            var eResult = response.ErrorCode;

            response.Dispose();
            return(sendSuccess ? eResult : TrinityErrorCode.E_NETWORK_SEND_FAILURE);
        }
        public override TrinityErrorCode SaveCell(long cell_id, byte *cellBytes, int cellSize, ushort cellType)
        {
            TrinityMessage msg = new TrinityMessage(TrinityMessageType.PRESERVED_SYNC_WITH_RSP, (ushort)RequestType.SaveCell, cellSize + 14 /*cell_type(2)+ cell_id(8) +cell_size(4)*/);
            byte *         p   = msg.Buffer + TrinityMessage.Offset;

            *(ushort *)p = cellType;
            p           += 2;

            *(long *)p = cell_id;
            p         += 8;

            *(int *)p = cellSize;
            p        += 4;

            Memory.Copy(cellBytes, p, cellSize);

            TrinityResponse response;

            Network.Client.SynClient sc = GetClient();
            bool sendSuccess            = (TrinityErrorCode.E_SUCCESS == sc.SendMessage(msg.Buffer, msg.Size, out response));

            PutBackClient(sc);
            msg.Dispose();

            var eResult = response.ErrorCode;

            response.Dispose();
            return(sendSuccess ? eResult : TrinityErrorCode.E_NETWORK_SEND_FAILURE);
        }
Beispiel #7
0
        internal unsafe static void FailureNotificationMessageHandler(ref SynReqRspArgs args)
        {
            int leaderCandidate = -1;
            int failureServerId = -1;

            {
                int *p = (int *)(args.Buffer + args.Offset);
                leaderCandidate = *p++;
                failureServerId = *p;
            }

            #region Debug
#if DEBUG
            Log.WriteLine(LogLevel.Info, "Received failure notification message from {0} who claim {1} failed.", leaderCandidate, failureServerId);
#endif
            #endregion

            TrinityMessage response = new TrinityMessage(34);

            {
                *(int *)response.Buffer = 30;
                long *p        = (long *)(response.Buffer + TrinityMessage.Offset);
                var   workload = SystemStatus.Workloads;
                *     p++      = workload.AvailableMemoryBytes; // 8
                *     p++      = workload.CellCount;            // 8
                *     p++      = workload.SliceSize;            //8
                *(int *)p = workload.SliceCount;                //4
            }

            args.Response = response;
        }
Beispiel #8
0
        private unsafe void PollEvents_impl(SynReqRspArgs args)
        {
            /******************************
            * Protocol: PollEvents
            * Request: |4B InstanceId|4B Cookie|
            * Response:[4B E_RESULT Header] - |8B p| TrinityMessage |
            * Response.p != 0 if the response is a "request with response"
            * Response.TrinityMessage length header < 0 if there are no events
            * E_RESULT values:
            *
            *      0 = E_SUCCESS
            *      1 = E_NO_EVENTS
            *      2 = E_INVALID_CLIENT
            *
            * !NOTE Here, response itself is a TrinityMessage and Response.TrinityMessage
            * is the inner payload.
            ******************************/
            PointerHelper  sp         = PointerHelper.New(args.Buffer + args.Offset);
            int            instanceId = *sp.ip++;
            int            cookie     = *sp.ip++;
            byte *         outer_buf;
            int            outer_len;
            long           p  = 0;
            TrinityMessage tm = null;
            TaskCompletionSource <bool> tsrc = null;
            bool invalid_client = false;

            try
            {
                var stg = CheckInstanceCookie(cookie, instanceId);
                stg.Pulse     = DateTime.Now;
                (p, tm, tsrc) = stg.PollEvents_impl();
            }
            catch (ClientInstanceNotFoundException)
            {
                invalid_client = true;
            }

            if (tm == null)
            {
                outer_len         = TrinityProtocol.MsgHeader + sizeof(long) + sizeof(int);
                outer_buf         = (byte *)Memory.malloc((ulong)outer_len);
                *(int *)outer_buf = outer_len - TrinityProtocol.SocketMsgHeader;
                *(long *)(outer_buf + TrinityProtocol.MsgHeader) = 0;
                *(int *)(outer_buf + TrinityProtocol.MsgHeader + sizeof(long)) = -1;
                *(int *)(outer_buf + TrinityProtocol.SocketMsgHeader)          = invalid_client ? 2 : 1;
            }
            else
            {
                outer_len         = TrinityProtocol.MsgHeader + sizeof(long) + tm.Size;
                outer_buf         = (byte *)Memory.malloc((ulong)outer_len);
                *(int *)outer_buf = outer_len - TrinityProtocol.SocketMsgHeader;
                *(long *)(outer_buf + TrinityProtocol.MsgHeader) = p;
                Memory.memcpy(outer_buf + TrinityProtocol.MsgHeader + sizeof(long), tm.Buffer, (ulong)tm.Size);
                tsrc.SetResult(true);
                *(int *)(outer_buf + TrinityProtocol.SocketMsgHeader) = 0;
            }
            args.Response = new TrinityMessage(outer_buf, outer_len);
        }
Beispiel #9
0
        internal static bool GetCommunicationModuleOffset(this IMessagePassingEndpoint storage, string moduleName, out ushort synReqOffset, out ushort synReqRspOffset, out ushort asynReqOffset, out ushort asynReqRspOffset)
        {
            /******************
            * Comm. protocol:
            *  - REQUEST : [char_cnt, char[] moduleName]
            *  - RESPONSE: [int synReqOffset, int synReqRspOffset, int asynReqOffset, int asynReqRspOffset]
            * An response error code other than E_SUCCESS indicates failure of remote module lookup.
            ******************/

            using (TrinityMessage tm = new TrinityMessage(
                       TrinityMessageType.PRESERVED_SYNC_WITH_RSP,
                       (ushort)RequestType.GetCommunicationModuleOffsets,
                       size: sizeof(int) + sizeof(char) * moduleName.Length))
            {
                PointerHelper sp = PointerHelper.New(tm.Buffer + TrinityMessage.Offset);
                *sp.ip++         = moduleName.Length;

                BitHelper.WriteString(moduleName, sp.bp);
                TrinityResponse response = null;
                bool            ret;
                try
                {
                    storage.SendMessage(tm, out response);
                    ret = (response.ErrorCode == TrinityErrorCode.E_SUCCESS);
                }
                catch (System.IO.IOException)
                {
                    ret = false;
                }

                if (ret)
                {
                    sp.bp = response.Buffer + response.Offset;
                    int synReq_msg     = *sp.ip++;
                    int synReqRsp_msg  = *sp.ip++;
                    int asynReq_msg    = *sp.ip++;
                    int asynReqRsp_msg = *sp.ip++;

                    synReqOffset     = (ushort)synReq_msg;
                    synReqRspOffset  = (ushort)synReqRsp_msg;
                    asynReqOffset    = (ushort)asynReq_msg;
                    asynReqRspOffset = (ushort)asynReqRsp_msg;
                }
                else
                {
                    synReqOffset     = 0;
                    synReqRspOffset  = 0;
                    asynReqOffset    = 0;
                    asynReqRspOffset = 0;
                }


                response?.Dispose();
                return(ret);
            }
        }
Beispiel #10
0
        private unsafe void _PollImpl(TrinityMessage poll_req)
        {
            m_mod.SendMessage(m_client, poll_req.Buffer, poll_req.Size, out var poll_rsp);
            var sp = PointerHelper.New(poll_rsp.Buffer + poll_rsp.Offset);
            //HexDump.Dump(poll_rsp.ToByteArray());
            //Console.WriteLine($"poll_rsp.Size = {poll_rsp.Size}");
            //Console.WriteLine($"poll_rsp.Offset = {poll_rsp.Offset}");
            var payload_len = poll_rsp.Size - TrinityProtocol.TrinityMsgHeader;

            if (payload_len < sizeof(long) + sizeof(int))
            {
                throw new IOException("Poll response corrupted.");
            }
            var errno = *(sp.ip - 1);

            try
            {
                if (errno == 2)
                {
                    Log.WriteLine(LogLevel.Warning, $"{nameof(TrinityClient)}: server drops our connection. Registering again.");
                    RestartPolling();
                    return;
                }
                if (errno != 0)
                {
                    return;
                }

                var pctx    = *sp.lp++;
                var msg_len = *sp.ip++;
                if (msg_len < 0)
                {
                    return;              // no events
                }
                MessageBuff msg_buff = new MessageBuff {
                    Buffer = sp.bp, Length = (uint)msg_len
                };
                MessageDispatcher(&msg_buff);
                // !Note, void-response messages are not acknowledged.
                // Server would not be aware of client side error in this case.
                // This is by-design and an optimization to reduce void-response
                // message delivery latency. In streaming use cases this will be
                // very useful.
                try { if (pctx != 0)
                      {
                          _PostResponseImpl(pctx, &msg_buff);
                      }
                }
                finally { Memory.free(msg_buff.Buffer); }
            }
            finally
            {
                poll_rsp.Dispose();
            }
        }
Beispiel #11
0
        private unsafe Task QueueMessage(void *p, int size)
        {
            TaskCompletionSource <bool> req_token = new TaskCompletionSource <bool>();

            m_req_tokens[(long)p] = req_token;
            TrinityMessage tm = new TrinityMessage((byte *)p, size);

            m_messages.Enqueue(tm);
            req_token.Task.ContinueWith(_free(p));
            return(req_token.Task);
        }
Beispiel #12
0
        internal unsafe string EchoPing(int serverId, string msg)
        {
            TrinityMessage trinity_msg = new TrinityMessage(TrinityMessageType.PRESERVED_SYNC_WITH_RSP, (ushort)RequestType.EchoPing, msg.Length << 1);

            BitHelper.WriteString(msg, trinity_msg.Buffer + TrinityMessage.Offset);

            TrinityResponse response;

            StorageTable[serverId].SendMessage(trinity_msg.Buffer, trinity_msg.Size, out response);

            return(BitHelper.GetString(response.Buffer + response.Offset, response.Size));
        }
Beispiel #13
0
        internal long GetTotalMemoryUsage()
        {
            TrinityMessage tm = new TrinityMessage(TrinityMessageType.PRESERVED_SYNC_WITH_RSP, (ushort)RequestType.QueryMemoryWorkingSet, 0);

            long[] memUsage = new long[ServerCount];
            Parallel.For(0, ServerCount, sid =>
            {
                TrinityResponse response;
                SendMessageToServer(sid, tm, out response);
                memUsage[sid] = *(long *)(response.Buffer + response.Offset);
            });
            return(memUsage.Sum());
        }
Beispiel #14
0
        public override long GetTotalMemoryUsage()
        {
            TrinityMessage tm = new TrinityMessage(TrinityMessageType.PRESERVED_SYNC_WITH_RSP, (ushort)RequestType.QueryMemoryWorkingSet, 0);

            long[] memUsage = new long[PartitionCount];
            Parallel.For(0, PartitionCount, sid =>
            {
                TrinityResponse response;
                StorageTable[sid].SendMessage(tm.Buffer, tm.Size, out response);
                memUsage[sid] = *(long *)(response.Buffer + response.Offset);
            });
            return(memUsage.Sum());
        }
Beispiel #15
0
        private unsafe (Task, Task <TrinityResponse>) QueueMessageWithRsp(void *p, int size)
        {
            TaskCompletionSource <bool>            req_token = new TaskCompletionSource <bool>();
            TaskCompletionSource <TrinityResponse> rsp_token = new TaskCompletionSource <TrinityResponse>();

            m_req_tokens[(long)p] = req_token;
            m_rsp_tokens[(long)p] = rsp_token;
            TrinityMessage tm = new TrinityMessage((byte *)p, size);

            m_messages.Enqueue(tm);
            req_token.Task.ContinueWith(_free(p));
            return(req_token.Task, rsp_token.Task);
        }
Beispiel #16
0
        internal static void P2PBarrierRequest(this Trinity.Storage.MemoryCloud storage, int taskId)
        {
            TrinityMessage msg = new TrinityMessage(TrinityMessageType.PRESERVED_SYNC, (ushort)RequestType.P2PBarrier, sizeof(int));

            *(int *)(msg.Buffer + TrinityMessage.Offset) = taskId;

            SpinLockInt32.GetLock(ref spin_lock);
            if (BSPCheckInCount.ContainsKey(taskId))
            {
                BSPCheckInCount[taskId]++;
            }
            else
            {
                BSPCheckInCount[taskId] = 1;
            }
            SpinLockInt32.ReleaseLock(ref spin_lock);

            Parallel.For(0, Global.ServerCount, i =>
            {
                if (i != Global.MyServerId)
                {
                    storage.SendMessageToServer(i, msg);
                }
            }
                         );

            int retry = 2048;

            while (true)
            {
                SpinLockInt32.GetLock(ref spin_lock);
                if (BSPCheckInCount[taskId] == Global.ServerCount)
                {
                    BSPCheckInCount.Remove(taskId);
                    SpinLockInt32.ReleaseLock(ref spin_lock);
                    return;
                }
                SpinLockInt32.ReleaseLock(ref spin_lock);
                if (--retry < 1024)
                {
                    if (retry > 0)
                    {
                        Thread.Yield();
                    }
                    else
                    {
                        Thread.Sleep(1);
                    }
                }
            }
        }
Beispiel #17
0
        internal override void SendMessage(TrinityMessage msg)
        {
            TrinityErrorCode err = TrinityErrorCode.E_SUCCESS;

            for (int i = 0; i < retry; i++)
            {
                SynClient sc = GetClient();
                err = sc.SendMessage(msg.Buffer, msg.Size);
                PutBackClient(sc);
                if (err == TrinityErrorCode.E_SUCCESS || err == TrinityErrorCode.E_RPC_EXCEPTION)
                {
                    break;
                }
            }
            _error_check(err);
        }
Beispiel #18
0
        /// <summary>
        /// Dumps memory storages to disk files on all Trinity servers.
        /// </summary>
        /// <returns>true if saving succeeds; otherwise, false.</returns>
        public override bool SaveStorage()
        {
            try
            {
                TrinityMessage msg = new TrinityMessage(TrinityMessageType.PRESERVED_SYNC, (ushort)RequestType.SaveStorage, 0);

                Parallel.ForEach <IStorage>(StorageTable, storage =>
                {
                    storage.SendMessage(msg);
                });
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Beispiel #19
0
        private unsafe void RedirectMessage_impl(SynReqArgs args)
        {
            /******************************
            * Protocol: RedirectMessage
            * Request: |4B PartitionId| TrinityMessage |
            * Response: VOID
            *
            * Redirects the message to another instance.
            ******************************/

            PointerHelper sp          = PointerHelper.New(args.Buffer + args.Offset);
            int           partitionId = *sp.ip++;

            TrinityMessage tm = new TrinityMessage(sp.bp, (*sp.ip) + TrinityProtocol.SocketMsgHeader);

            m_memorycloud[partitionId].SendMessage(tm);
        }
Beispiel #20
0
        private unsafe void RedirectMessage_impl(SynReqArgs args)
        {
            /******************************
            * Protocol: RedirectMessage
            * Request: |4B InstanceId| TrinityMessage |
            * Response: VOID
            *
            * Redirects the message to another instance.
            ******************************/

            PointerHelper sp         = PointerHelper.New(args.Buffer + args.Offset);
            int           instanceId = *sp.ip++;

            TrinityMessage tm = new TrinityMessage(sp.bp, *sp.ip + sizeof(int));

            m_memorycloud[instanceId].SendMessage(tm);
        }
Beispiel #21
0
        /// <summary>
        /// Resets local memory storage to the initial state on all Trinity servers. The content in the memory storage will be cleared. And the memory storage will be shrunk to the initial size.
        /// </summary>
        /// <returns>true if resetting succeeds; otherwise, false.</returns>
        public bool ResetStorage()
        {
            try
            {
                TrinityMessage msg = new TrinityMessage(TrinityMessageType.PRESERVED_SYNC, (ushort)RequestType.ResetStorage, 0);

                Parallel.ForEach <Storage>(StorageTable, s =>
                {
                    s.SendMessage(msg);
                }
                                           );
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Beispiel #22
0
        private async Task PollProc(CancellationToken token)
        {
            TrinityMessage poll_req = _AllocPollMsg(m_id, m_cookie);

            while (!token.IsCancellationRequested)
            {
                try
                {
                    _PollImpl(poll_req);
                    await Task.Delay(100);
                }
                catch (Exception ex)
                {
                    Log.WriteLine(LogLevel.Error, $"{nameof(TrinityClient)}: error occured during polling: {{0}}", ex.ToString());
                    await Task.Delay(100);
                }
            }
            poll_req.Dispose();
        }
        public override TrinityErrorCode RemoveCell(long cell_id)
        {
            TrinityMessage msg = new TrinityMessage(TrinityMessageType.PRESERVED_SYNC_WITH_RSP, (ushort)RequestType.RemoveCell, sizeof(long));

            *(long *)(msg.Buffer + TrinityMessage.Offset) = cell_id;

            TrinityResponse response;

            Network.Client.SynClient sc = GetClient();
            bool sendSuccess            = (TrinityErrorCode.E_SUCCESS == sc.SendMessage(msg.Buffer, msg.Size, out response));

            PutBackClient(sc);
            msg.Dispose();

            var eResult = response.ErrorCode;

            response.Dispose();

            return(sendSuccess ? eResult : TrinityErrorCode.E_NETWORK_SEND_FAILURE);
        }
        /// <inheritdoc/>
        public void SendMessage(byte *message, int size, out TrinityResponse response)
        {
            MessageBuff buff = new MessageBuff();

            buff.Buffer = message;
            buff.Length = (uint)size;

            LocalSendMessage(&buff);

            int response_len = *(int *)buff.Buffer;

            if (buff.Length != response_len + sizeof(int))
            {
                throw new IOException("Local message handler throws an exception.");
            }
            else
            {
                TrinityMessage rsp_message = new TrinityMessage(buff.Buffer, (int)buff.Length);
                response = new TrinityResponse(rsp_message);
            }
        }
Beispiel #25
0
        internal static void GetCommunicationSchema(this IMessagePassingEndpoint storage, out string name, out string signature)
        {
            /******************
            * Comm. protocol:
            *  - REQUEST : VOID
            *  - RESPONSE: [char_cnt, char[] name, char_cnt, char[] sig]
            ******************/
            using (TrinityMessage tm = new TrinityMessage(
                       TrinityMessageType.PRESERVED_SYNC_WITH_RSP,
                       (ushort)RequestType.GetCommunicationSchema,
                       size: 0))
            {
                TrinityResponse response;
                storage.SendMessage(tm, out response);
                PointerHelper sp = PointerHelper.New(response.Buffer + response.Offset);
                int           name_string_len = *sp.ip++;
                name   = BitHelper.GetString(sp.bp, name_string_len * 2);
                sp.cp += name_string_len;
                int sig_string_len = *sp.ip++;
                signature = BitHelper.GetString(sp.bp, sig_string_len * 2);

                response.Dispose();
            }
        }
 internal void SendMessageToServer(int serverId, TrinityMessage msg)
 {
     StorageTable[serverId].SendMessage(msg);
 }
Beispiel #27
0
        internal unsafe void ShutDownProxy(RemoteStorage proxy)
        {
            TrinityMessage msg = new TrinityMessage(TrinityMessageType.PRESERVED_ASYNC, (ushort)RequestType.Shutdown, 0);

            proxy.SendMessage(msg.Buffer, msg.Size);
        }
Beispiel #28
0
 private unsafe void _SetSendRecvBuff(TrinityErrorCode msgProcessResult, MessageBuff *sendRecvBuff, TrinityMessage response)
 {
     if (TrinityErrorCode.E_SUCCESS == msgProcessResult)
     {
         // Response buffer will be freed in Trinity.C after it is sent
         sendRecvBuff->Buffer = response.Buffer;
         sendRecvBuff->Length = (uint)response.Size;
     }
     else// TrinityErrorCode.E_RPC_EXCEPTION == msgProcessResult
     {
         //  The client is expecting a reply payload, it will be notified because
         //  the payload length is E_RPC_EXCEPTION;
         sendRecvBuff->Buffer = (byte *)Memory.malloc(sizeof(TrinityErrorCode));
         sendRecvBuff->Length = sizeof(TrinityErrorCode);
         *(TrinityErrorCode *)sendRecvBuff->Buffer = TrinityErrorCode.E_RPC_EXCEPTION;
     }
 }
 internal void SendMessageToServer(int serverId, TrinityMessage msg, out TrinityResponse response)
 {
     StorageTable[serverId].SendMessage(msg, out response);
 }
Beispiel #30
0
 public static void SendMessage(this IMessagePassingEndpoint storage, TrinityMessage message, out TrinityResponse response)
 {
     storage.SendMessage(message.Buffer, message.Size, out response);
 }