Ejemplo n.º 1
0
        private void ResetPerfMoniter()
        {
            if (m_PerfMonitor != null)
            {
                m_PerfMonitor.Stop();
                m_PerfMonitor.Dispose();
                m_PerfMonitor = null;
            }

            m_PerfMonitor = new PerformanceMonitor(m_Config, m_AppServers, m_ServerManager);
            m_PerfMonitor.Start();

            m_GlobalLog.Debug("The PerformanceMonitor has been reset for new server has been added!");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultBootstrap"/> class.
        /// </summary>
        /// <param name="rootConfig">The root config.</param>
        /// <param name="appServers">The app servers.</param>
        /// <param name="logFactory">The log factory.</param>
        public DefaultBootstrap(IRootConfig rootConfig, IEnumerable <IWorkItem> appServers)
        {
            if (rootConfig == null)
            {
                throw new ArgumentNullException("rootConfig");
            }

            if (appServers == null)
            {
                throw new ArgumentNullException("appServers");
            }

            if (!appServers.Any())
            {
                throw new ArgumentException("appServers must have one item at least", "appServers");
            }


            m_RootConfig = rootConfig;

            SetDefaultCulture(rootConfig);

            m_AppServers = appServers.ToList();

            m_GlobalLog = LoggerManager.GetLogger(this.GetType().Name);

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            if (!rootConfig.DisablePerformanceDataCollector)
            {
                m_PerfMonitor = new PerformanceMonitor(rootConfig, m_AppServers, null);


                m_GlobalLog.Debug("The PerformanceMonitor has been initialized!");
            }

            m_GlobalLog.Debug("The Bootstrap has been initialized!");

            m_Initialized = true;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes the bootstrap with the configuration, config resolver and log factory.
        /// </summary>
        /// <param name="serverConfigResolver">The server config resolver.</param>
        /// <param name="logFactory">The log factory.</param>
        /// <returns></returns>
        public virtual bool Initialize(Func <IServerConfig, IServerConfig> serverConfigResolver)
        {
            if (m_Initialized)
            {
                throw new Exception("The server had been initialized already, you cannot initialize it again!");
            }

            IEnumerable <WorkItemFactoryInfo> workItemFactories;

            using (var factoryInfoLoader = GetWorkItemFactoryInfoLoader(m_Config))
            {
                m_GlobalLog = LoggerManager.GetLogger(this.GetType().Name);

                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                try
                {
                    workItemFactories = factoryInfoLoader.LoadResult(serverConfigResolver);
                }
                catch (Exception e)
                {
                    m_GlobalLog.Error(e.ToString());

                    return(false);
                }
            }

            m_AppServers = new List <IWorkItem>(m_Config.Servers.Count());

            IWorkItem serverManager = null;

            //Initialize servers
            foreach (var factoryInfo in workItemFactories)
            {
                IWorkItem appServer = InitializeAndSetupWorkItem(factoryInfo);

                if (appServer == null)
                {
                    return(false);
                }

                if (factoryInfo.IsServerManager)
                {
                    serverManager = appServer;
                }
                else if (!(appServer is IsolationAppServer))//No isolation
                {
                    //In isolation mode, cannot check whether is server manager in the factory info loader
                    if (TypeValidator.IsServerManagerType(appServer.GetType()))
                    {
                        serverManager = appServer;
                    }
                }

                m_AppServers.Add(appServer);
            }

            if (serverManager != null)
            {
                m_ServerManager = serverManager;
            }

            if (!m_Config.DisablePerformanceDataCollector)
            {
                m_PerfMonitor = new PerformanceMonitor(m_Config, m_AppServers, serverManager);

                m_GlobalLog.Debug("The PerformanceMonitor has been initialized!");
            }

            m_GlobalLog.Debug("The Bootstrap has been initialized!");

            try
            {
#if !NETSTANDARD2_0
                RegisterRemotingService();
#endif
            }
            catch (Exception e)
            {
                m_GlobalLog.Error("Failed to register remoting access service!", e);

                return(false);
            }

            m_Initialized = true;

            return(true);
        }