Пример #1
0
        /// <summary>
        /// 初始化服务器
        /// </summary>
        /// <param name="col"></param>
        private static string InitServer(ServerCollection col)
        {
            StringBuilder sb = new StringBuilder();
            bool          hasRegisterLocalServer = false;

            if (col != null && col.Count > 0)
            {
                IList <IServerInfo> serverList = ConfigHelper.GetServerInfoList(col);
                foreach (IServerInfo s in serverList)
                {
                    sb.Append(s);
                    ServerManager.Register(s);
                    //服务器如果是自己才注册通道和服务
                    if (IPHelper.IsLocalIP(s.Address))
                    {
                        if (s.IsProvideService)
                        {
                            ServerManager.RegisterServerChannel(s);
                            ServerManager.RegisterService(s);
                        }
                        else
                        {
                            ServerManager.RegisterClientChannel(s);
                        }
                        hasRegisterLocalServer = true;
                    }
                }
            }
            //如果没有注册本地服务,则在此注册
            if (!hasRegisterLocalServer)
            {
                ServerManager.RegisterClientChannel("tcp");
            }
            return(sb.ToString());
        }
Пример #2
0
        public static LogMessage CreateHandleLogEntity(string logType, string iKey)
        {
            var handlelog = new LogMessage
            {
                Ikey     = iKey,
                Username = "******",
                Module   = "nomodule",
                LogType  = logType,
                Content  = "nocontent",
                IsHandle = false,
                Keyword  = "nokeyword",
                OrderNo  = "noorderno",
                ClientIP = ClientHelper.GetClientIP(),
                ServerIP = IPHelper.GetLocalIP(),
            };

            if (string.IsNullOrEmpty(iKey))
            {
                handlelog.Ikey = Guid.NewGuid().ToString();
            }
            return(handlelog);
        }
Пример #3
0
        static DBLog()
        {
            try
            {
                m_localLog = LoggerSource.Instance.GetLogger(typeof(DBLog));

                AppSetting.InitDistributionConfig();
                m_logToServer   = AppSetting.LogToServer;
                m_localServer   = ServerManager.GetLocalServer();
                m_localServerIP = IPHelper.GetLocalIP();

                m_localServerCode = m_localServer != null ? m_localServer.ServerCode : m_localServerIP;
                if (m_openLogCenter)
                {
#if THRIFT
                    ZKManager.Client.Init();
                    InitThriftServer();
#endif
                }

                m_request = RegisterService.TaskRequestService.GetService(m_logToServer);

                m_logHandlePool = new DataBufferPool(BatchSendHandleRequest)
                {
                    AutoFlushLogSeconds = 5,
                    IsBlockMainThread   = false
                };
                m_logProcessPool = new DataBufferPool(BatchSendProcessRequest)
                {
                    AutoFlushLogSeconds = 3,
                    IsBlockMainThread   = false
                };
            }
            catch (Exception ex)
            {
                m_localLog.Error(ex);
            }
        }
Пример #4
0
 public static IServerInfo GetLocalServer()
 {
     return(GetByIP(IPHelper.GetLocalIPList()));
 }