/// <summary> /// Initializes a new instance of the <see cref="TcpServerReplication"/> class. /// </summary> public TcpServerReplication() { #region Access Log #if TRACE { COM.Handler.LogHandler.Tracking("Access Method: " + this.GetType().ToString() + "->" + ((object)MethodBase.GetCurrentMethod()).ToString() + " ;"); } #endif #endregion Access Log Thread.CurrentThread.Name = "TcpServerReplication"; this.replicationQueue = new Queue <SharedCache.WinServiceCommon.IndexusMessage>(10000); this.threadPool = new COM.Threading.SharedCacheThreadPool(3, 25, "TcpReplication"); if (this.enableServiceFamilyMode) { foreach (string n in COM.Provider.Server.IndexusServerReplicationCache.CurrentProvider.Servers) { string msg = "Defined server by provider: " + n; #if DEBUG Console.WriteLine(msg); #endif COM.Handler.LogHandler.Info(msg); } Console.WriteLine(@"- - - - - - - - -"); Console.WriteLine(); } }
/// <summary> /// Initializes a new instance of the <see cref="T:Tcp"/> class. /// </summary> public TcpServer() { #region Access Log #if TRACE { COM.Handler.LogHandler.Tracking("Access Method: " + this.GetType().ToString() + "->" + ((object)MethodBase.GetCurrentMethod()).ToString() + " ;"); } #endif #endregion Access Log #region validate first if provided configuration is a numeric value - ConfigCacheAmountOfObjects if (!string.IsNullOrEmpty(COM.Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.CacheAmountOfObjects.ToString()) && long.TryParse( COM.Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.CacheAmountOfObjects.ToString(), out this.cacheAmountOfObjects) && COM.Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.CacheAmountOfObjects > 0 ) { // calculate the correct size for max cache size this.cacheAmountOfObjects = long.Parse(COM.Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.CacheAmountOfObjects.ToString()) * (1024 * 1024); } else { this.cacheAmountOfObjects = -1; } #endregion validate first if provided configuration is a numeric value - ConfigCacheAmountOfObjects #region validate first if provided configuration is a numeric value - ConfigCacheAmountFillFactorInPercentage if (!string.IsNullOrEmpty( COM.Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.CacheAmountFillFactorInPercentage.ToString()) && long.TryParse( COM.Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.CacheAmountFillFactorInPercentage.ToString(), out this.cacheAmountFillFactorInPercentage) ) { // this defines the purge factor for the dictonary this.cacheAmountFillFactorInPercentage = long.Parse( COM.Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.CacheAmountFillFactorInPercentage.ToString()); } else { this.cacheAmountFillFactorInPercentage = 90; } #endregion validate first if provided configuration is a numeric value - ConfigCacheAmountFillFactorInPercentage this.maxSockets = 30000; this.conntectedSockets = new ArrayList(this.maxSockets); #region Thread Pool Configuration int minThreadsInPool = 3; int maxThreadsInPool = 25; // validate min threads if (minThreadToSet > minThreadsInPool) { minThreadsInPool = minThreadToSet; } // validate max threads if (maxThreadToSet > maxThreadsInPool) { maxThreadsInPool = maxThreadToSet; } // recheck that min. amount is smaller then max. - set default values if this happend if (minThreadsInPool >= maxThreadsInPool) { minThreadsInPool = 3; maxThreadsInPool = 25; } #endregion Thread Pool Configuration try { // Init thread pool this.threadPool = new COM.Threading.SharedCacheThreadPool(minThreadsInPool, maxThreadsInPool, "TcpServer"); COM.Handler.LogHandler.Info(string.Format("Configuration: Thread Pool initalized with min:{0} and max:{1} Threads", minThreadsInPool, maxThreadsInPool)); Console.WriteLine("Configuration: Thread Pool initalized with min:{0} and max:{1} Threads", minThreadsInPool, maxThreadsInPool); } catch (Exception) { this.threadPool = null; COM.Handler.LogHandler.Error("Configuration Error: Thread Pool initalized with min: 3 and max: 25 Threads"); } finally { if (this.threadPool == null) { minThreadsInPool = 3; maxThreadsInPool = 25; this.threadPool = new COM.Threading.SharedCacheThreadPool(minThreadsInPool, maxThreadsInPool, "TcpServer"); COM.Handler.LogHandler.Error("Configuration Error: Thread Pool initalized with min: 3 and max: 25 Threads"); } } this.threadPool.Priority = ThreadPriority.AboveNormal; this.threadPool.NewThreadTrigger = 1; this.threadPool.DynamicThreadDecay = 5000; this.threadPool.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="TcpServerReplication"/> class. /// </summary> public TcpServerReplication() { #region Access Log #if TRACE { COM.Handler.LogHandler.Tracking("Access Method: " + this.GetType().ToString() + "->" + ((object)MethodBase.GetCurrentMethod()).ToString() + " ;"); } #endif #endregion Access Log Thread.CurrentThread.Name = "TcpServerReplication"; this.replicationQueue = new Queue<SharedCache.WinServiceCommon.IndexusMessage>(10000); this.threadPool = new COM.Threading.SharedCacheThreadPool(3, 25, "TcpReplication"); if (this.enableServiceFamilyMode) { foreach (string n in COM.Provider.Server.IndexusServerReplicationCache.CurrentProvider.Servers) { string msg = "Defined server by provider: " + n; #if DEBUG Console.WriteLine(msg); #endif COM.Handler.LogHandler.Info(msg); } Console.WriteLine(@"- - - - - - - - -"); Console.WriteLine(); } }