/// <summary> /// 初始化属于指定服务角色的系统工作者 /// </summary> /// <param name="role">服务角色</param> /// <param name="setting">远程配置设置</param> /// <param name="configurationProxy">远程配置站访问代理器</param> /// <param name="notificationHandler">异常通知处理器</param> /// <param name="proxy">KAE资源代理器</param> /// <exception cref="ArgumentNullException">参数不能为空</exception> public static void Initialize(string role, RemoteConfigurationSetting setting, IRemoteConfigurationProxy configurationProxy, ITracingNotificationHandler notificationHandler = null, IKAEResourceProxy proxy = null) { if (IsInitialized) { return; } if (setting == null) { setting = RemoteConfigurationSetting.Default; } if (proxy == null) { proxy = new KAEHostResourceProxy(); } if (string.IsNullOrEmpty(role)) { throw new ArgumentNullException(nameof(role)); } if (configurationProxy == null) { throw new ArgumentNullException(nameof(configurationProxy)); } SystemConfigurations.Initialize(role, setting, configurationProxy); _tracing = TracingManager.GetTracing(typeof(SystemWorker));; TransactionGlobal.Initialize(); _configurationProxy = configurationProxy; _hostProxy = proxy; TracingManager.NotificationHandler = notificationHandler ?? new RemoteLogProxy(); InitializeCore(role); //initialize long...long memory buffer for tcp layer. ChannelConst.Initialize(); _isInitialized = true; IsInSpecifiedKPP = false; }
public void SendData <T>(string methodName, T args) { if (!_enabled) { return; } int retryCount = 0; while (retryCount < 3) { try { _proxy.Invoke <T, RpcNull>(methodName, args); return; } catch (Exception ex) { SystemLog.Warn(LogEventID.TracingFailed, ex, "TracingSniffer<{0}> Failed! try: {1}", _url, retryCount); Thread.Sleep(3000 * retryCount); retryCount++; } } _enabled = false; _queueTracing.Dispose(); _queueSystemLog.Dispose(); SystemLog.Warn(LogEventID.TracingFailed, "TracingSniffer<{0}> over MaxError, AutoDisabled", _url); TracingManager.RemoveSniffer(Url); }
public RpcServerObserverItem(string service, string method, string fromService, string fromComputer) { Service = service; Method = method; FromService = fromService; FromComputer = fromComputer; RequestTracer = TracingManager.GetTracing(string.Format("RpcServer.{0}.{1}.Request", service, method)); ResponseTracer = TracingManager.GetTracing(string.Format("RpcServer.{0}.{1}.Response", service, method)); }
public RpcClientObserverItem(string serverUri, string service, string method, string serviceRole) { ServerUri = serverUri; Service = service; Method = method; ServiceRole = serviceRole; RequestTracer = TracingManager.GetTracing(string.Format("RpcClient.{0}.{1}.Request", service, method)); ResponseTracer = TracingManager.GetTracing(string.Format("RpcClient.{0}.{1}.Response", service, method)); }
private void WriteLog(int sniffMask, TracingLevel level, Exception ex, string from, string to, string message) { // NextVersion //int repeat; //if (TracingManager.AntiRepeat && !sniffed) { // if (AntiRepeater.IsRepeated(out repeat)) { // return; // } //} else { // repeat = 1; //} //if (repeat > 1) { // message = string.Format("!!!Repeat {0} times in last 5 seconds\r\n{1}", repeat, message); //} TracingEvent evt = new TracingEvent(); evt.Level = level; evt.LoggerName = _loggerName; evt.Time = DateTime.Now; evt.Message = message; evt.ProcessInfo = ServiceEnvironment.ProcessInfo; evt.ServiceName = ServiceEnvironment.ServiceName; evt.ComputerName = ServiceEnvironment.ComputerName; evt.ThreadInfo = TracingHelper.FormatThreadInfo(Thread.CurrentThread); evt.From = from ?? ""; evt.To = to ?? ""; evt.Error = ex == null ? "" : ex.ToString(); evt.Repeat = 1; // repeat; if (sniffMask > 0) { for (int i = 0; i < TracingSniffer.MaxSniffer; i++) { if ((sniffMask & (1 << i)) > 0) { TracingSniffer sniffer = _sniffers[i]; if (sniffer != null) { sniffer.Enqueue(evt); } } } } if (evt.Level == TracingLevel.Error) { _observerItem.LastError = evt.Message; if (ex != null) { _observerItem.LastException = evt.Error; } } TracingManager.Enqueue(evt); }
public TccCoordinator(string transName) { _transName = transName; _activeTrans = new Dictionary <string, TccTransaction <TContext> >(); _tracing = TracingManager.GetTracing("TccTransaction." + _transName); _counter = IICPerformanceCounterFactory.GetCounters <TccTransactionPerfCounter>(transName); _monitorThread = new Thread(MonitorProc); _monitorThread.IsBackground = false; _monitorThread.Name = "TccCoordinator.MonitorProc<" + _transName + ">"; }
static void Main(string[] args) { ServiceSettings.InitService("IICCommon"); ITracing tracing = TracingManager.GetTracing(typeof(Program)); tracing.Info("test"); LinkedNode <string> linkedNode = new LinkedNode <string>(); linkedNode.Value = "1"; linkedNode.AddNext("2"); linkedNode.AddNext("3"); foreach (string str in linkedNode.GetValues()) { Console.WriteLine(str); } Console.ReadLine(); }
/// <summary> /// 为KPP专门设计的初始化SystemWorker的函数 /// </summary> /// <param name="role">服务角色</param> /// <param name="proxy">KAE资源代理器</param> /// <param name="settings">KJFramework网络层设置集</param> /// <param name="appUniqueId">APP唯一编号</param> /// <exception cref="ArgumentNullException">参数不能为空</exception> internal static void InitializeForKPP(string role, IKAEResourceProxy proxy, ChannelInternalConfigSettings settings, Guid appUniqueId) { if (IsInitialized) { return; } if (string.IsNullOrEmpty(role)) { throw new ArgumentNullException(nameof(role)); } _hostProxy = proxy; _appUniqueId = appUniqueId; _configurationProxy = new KPPConfigurationProxy(proxy); SystemConfigurations.Initialize(role, RemoteConfigurationSetting.Default, _configurationProxy); _tracing = TracingManager.GetTracing(typeof(SystemWorker));; TransactionGlobal.Initialize(); //Regist("LGS", new LGSProtocolStack()); TracingManager.NotificationHandler = new RemoteLogProxy(); InitializeCore(role); //initialize long...long memory buffer for tcp layer. ChannelConst.Initialize(settings); _isInitialized = true; IsInSpecifiedKPP = true; }
public static void MyClassCleanup() { TracingManager.FlushCache(); }