///<summary> /// return true means the transaction has been flushed. ///</summary> ///<param name="transaction"> </param> ///<returns> true if message is flushed, false otherwise </returns> public bool End(ITransaction transaction) { if (_mStack.Count != 0) { var current = _mStack.Pop(); if (transaction == current) { ValidateTransaction(_mStack.Count == 0 ? null : _mStack.Peek(), current); } else { while (transaction != current && _mStack.Count != 0) { ValidateTransaction(_mStack.Peek(), current); current = _mStack.Pop(); } } if (_mStack.Count == 0) { var tree = _mTree.Copy(); _mTree.MessageId = null; _mTree.Message = null; _manager.Flush(tree); return(true); } } return(false); }
///<summary> /// return true means the transaction has been flushed. ///</summary> ///<param name="manager"> </param> ///<param name="transaction"> </param> ///<returns> true if message is flushed, false otherwise </returns> public bool End(DefaultMessageManager manager, ITransaction transaction) { if (_mStack.Count != 0) { ITransaction current = _mStack.Pop(); if (transaction == current) { ValidateTransaction(manager, _mStack.Count == 0 ? null : _mStack.Peek(), current); } else { while (transaction != current && _mStack.Count != 0) { ValidateTransaction(manager, _mStack.Peek(), current); current = _mStack.Pop(); } } if (_mStack.Count == 0) { IMessageTree tree = _mTree.Copy(); _mTree.MessageId = null; _mTree.Message = null; manager.Flush(tree); return true; } } return false; }
private void TruncateAndFlush(DefaultMessageManager manager, long timestamp) { IMessageTree tree = _mTree; Stack <ITransaction> stack = _mStack; IMessage message = tree.Message; if (message is DefaultTransaction) { if (tree.MessageId == null) { tree.MessageId = manager.NextMessageId(); } string rootId = tree.RootMessageId; string childId = manager.NextMessageId(); DefaultTransaction source = message as DefaultTransaction; DefaultTransaction target = new DefaultTransaction(source.Type, source.Name, manager); target.Timestamp = source.Timestamp; target.DurationInMicros = source.DurationInMicros; target.AddData(source.Data); target.Status = PureCatConstants.SUCCESS; MigrateMessage(manager, stack, source, target, 1); var list = stack.ToList(); for (int i = list.Count - 1; i >= 0; i--) { DefaultTransaction tran = list[i] as DefaultTransaction; tran.Timestamp = timestamp; tran.DurationInMicros = -1; } IEvent next = new DefaultEvent(PureCatConstants.TYPE_REMOTE_CALL, "Next"); next.AddData(childId); next.Status = PureCatConstants.SUCCESS; target.AddChild(next); IMessageTree t = tree.Copy(); t.Message = target; _mTree.MessageId = childId; _mTree.ParentMessageId = tree.MessageId; _mTree.RootMessageId = rootId ?? tree.MessageId; manager.Flush(t); } }
/// <summary> /// 添加Event和Heartbeat /// </summary> /// <param name="manager"> </param> /// <param name="message"> </param> public void Add(DefaultMessageManager manager, IMessage message) { if ((_mStack.Count == 0)) { var tree = _mTree.Copy(); tree.MessageId = manager.NextMessageId(); tree.Message = message; manager.Flush(tree); } else { var entry = _mStack.Peek(); entry.AddChild(message); } }
private void TruncateAndFlush(DefaultMessageManager manager, long timestamp) { IMessageTree tree = _mTree; Stack<ITransaction> stack = _mStack; IMessage message = tree.Message; if (message is DefaultTransaction) { if (tree.MessageId == null) { tree.MessageId = manager.NextMessageId(); } string rootId = tree.RootMessageId; string childId = manager.NextMessageId(); DefaultTransaction source = message as DefaultTransaction; DefaultTransaction target = new DefaultTransaction(source.Type, source.Name, manager); target.Timestamp = source.Timestamp; target.DurationInMicros = source.DurationInMicros; target.AddData(source.Data); target.Status = PureCatConstants.SUCCESS; MigrateMessage(manager, stack, source, target, 1); var list = stack.ToList(); for (int i = list.Count - 1; i >= 0; i--) { DefaultTransaction tran = list[i] as DefaultTransaction; tran.Timestamp = timestamp; tran.DurationInMicros = -1; } IEvent next = new DefaultEvent(PureCatConstants.TYPE_REMOTE_CALL, "Next"); next.AddData(childId); next.Status = PureCatConstants.SUCCESS; target.AddChild(next); IMessageTree t = tree.Copy(); t.Message = target; _mTree.MessageId = childId; _mTree.ParentMessageId = tree.MessageId; _mTree.RootMessageId = rootId ?? tree.MessageId; manager.Flush(t); } }
/// <summary> /// 添加Event和Heartbeat /// </summary> /// <param name="manager"> </param> /// <param name="message"> </param> public void Add(DefaultMessageManager manager, IMessage message) { if ((_mStack.Count == 0)) { IMessageTree tree = _mTree.Copy(); tree.MessageId = manager.NextMessageId(); tree.Message = message; manager.Flush(tree); } else { ITransaction entry = _mStack.Peek(); entry.AddChild(message); } }