internal Connection(Broker container, OnCommandRecieved commandRecieved, OnServerLost serverLost, Logs logs, PerfStatsCollector perfStatsCollector, ResponseIntegrator rspIntegraotr, string bindIP, string cacheName) { _container = container; _commandRecieved = commandRecieved; _serverLost = serverLost; _logger = logs; _responseIntegrator = rspIntegraotr; _cacheId = cacheName; _perfStatsColl = perfStatsCollector; SetBindIP(bindIP); if (System.Configuration.ConfigurationSettings.AppSettings["EnableNaggling"] != null) { _nagglingEnabled = Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["EnableNaggling"]); } //read the naggling size from app.config and covert it to bytes. if (System.Configuration.ConfigurationSettings.AppSettings["NagglingSize"] != null) { _nagglingSize = 1024 * Convert.ToInt64(System.Configuration.ConfigurationSettings.AppSettings["NagglingSize"]); } if (System.Configuration.ConfigurationSettings.AppSettings["EnableDualSockets"] != null) { _supportDualSocket = Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["EnableDualSockets"]); } }
/// <summary> /// Starts the socket server.It registers some types with compact Framework, /// enables simple logs as well as DetailedLogs, then it checks Ncache licence information. /// starts connection manager and perfmon counters. /// </summary> /// <param name="bindIP" ></param> /// public void Start(IPAddress bindIP, LoggerNames loggerName, string perfStatColInstanceName, CommandManagerType cmdMgrType, ConnectionManagerType conMgrType) { if (loggerName == null) { _loggerName = LoggerNames.SocketServerLogs; } else { _loggerName = loggerName; } InitializeLogging(); #if JAVA _perfStatsColl = new PerfStatsCollector("TayzGrid Server", _serverPort); #else _perfStatsColl = new PerfStatsCollector(cacheName, _serverPort); #endif _conManager = new ConnectionManager(_perfStatsColl); _conManager.Start(bindIP, _serverPort, _sendBuffer, _recieveBuffer, _logger, cmdMgrType, conMgrType); if (ConnectionManagerType.HostClient == conMgrType) { _hostClientConnectionManager = _conManager; } // We initialize PerfstatsCollector only for SocketServer's instance for client. // Management socket server has just DUMMY stats collector. if (conMgrType == ConnectionManagerType.HostClient) { _perfStatsColl.InitializePerfCounters(); } }
public DedicatedMessageSender(Alachisoft.NCache.Common.DataStructures.Queue mq, ConnectionTable.Connection connection, object syncLockObj, ILogger NCacheLog, bool onPrimaryNIC, bool doNaggling, int naglingSize) { this.mq = mq; this.peerConnection = connection; if (connection != null) { string primary = connection.IsPrimary ? "p" : "s"; string primaryNIC = onPrimaryNIC ? "p" : "s"; Name = "DmSender - " + connection.peer_addr.ToString() + " - " + primary + primaryNIC; } perfStatsCollector = peerConnection.Enclosing_Instance.enclosingInstance.Stack.perfStatsColl; IsBackground = true; sync_lock = syncLockObj; _ncacheLog = NCacheLog; isNagglingEnabled = doNaggling; nagglingSize = naglingSize; if (nagglingSize + 8 > sendBufferSize) { sendBufferSize = nagglingSize + 8; } sendBuffer = new byte[sendBufferSize]; }
private void Initialize(Broker container, OnCommandRecieved commandRecieved, OnServerLost serverLost, Logs logs, PerfStatsCollector perfStatsCollector, ResponseIntegrator rspIntegraotr, string bindIP, string cacheName) { _commandRecieved = null; _serverLost = null; _isConnected = true; _primaryClient = null; _secondaryClient = null; _ipAddress = string.Empty; _intendedRecipientIPAddress = string.Empty; _port = 0; _connectionMutex = new object(); _connectionStatusLatch = new Latch(ConnectionStatus.Disconnected); s_receiveBufferSize = 2048000; _processID = System.Diagnostics.Process.GetCurrentProcess().Id; _primaryReceiveThread = null; _secondaryReceiveThread = null; _notificationsRegistered = false; _isReconnecting = false; _forcedDisconnect = false; _nagglingEnabled = false; _nagglingSize = 5 * 100 * 1024; //500k _supportDualSocket = false; _syncLock = new object(); _perfStatsColl = null; _socketSelectionMutex = new object(); _usePrimary = true; _optimized = false; _isIdle = false; _container = container; _commandRecieved = commandRecieved; _serverLost = serverLost; _logger = logs; _responseIntegrator = rspIntegraotr; _cacheId = cacheName; _perfStatsColl = perfStatsCollector; SetBindIP(bindIP); if (System.Configuration.ConfigurationSettings.AppSettings["EnableNaggling"] != null) { _nagglingEnabled = Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["EnableNaggling"]); } //read the naggling size from app.config and covert it to bytes. if (System.Configuration.ConfigurationSettings.AppSettings["NagglingSize"] != null) { _nagglingSize = 1024 * Convert.ToInt64(System.Configuration.ConfigurationSettings.AppSettings["NagglingSize"]); } if (System.Configuration.ConfigurationSettings.AppSettings["EnableDualSockets"] != null) { _supportDualSocket = Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["EnableDualSockets"]); } }
public CommandProcessor(IRequestProcessor processor, PerfStatsCollector collector) { _processor = processor; _commandsQueue = new Queue <ProcCommand>(); _worker = new Thread(Run); _worker.IsBackground = true; _worker.Priority = ThreadPriority.AboveNormal; }
public CommandManager(PerfStatsCollector perfStatsCollector) { _perfStatsCollector = perfStatsCollector; CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Caching.OperationContext), 153); CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataStructures.EnumerationPointer), 161); CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataStructures.EnumerationDataChunk), 162); }
public CommandProcessorPool(int processors, IRequestProcessor reqProcessor, PerfStatsCollector collector) { _maxProcessors = processors; _workers = new CommandProcessor[processors]; for (int i = 0; i < processors; i++) { _workers[i] = new CommandProcessor(reqProcessor, collector); } }
public RequestLogManager(PerfStatsCollector statsCollector) { _statsCollector = statsCollector; if (ServiceConfiguration.EnableRequestInquiry) { if (ServiceConfiguration.RequestInquiryCleanInterval != 0) { _logCleanInterval = ServiceConfiguration.RequestInquiryCleanInterval; } _clientRequestLog = new Dictionary <string, Dictionary <long, RequestStatus> >(); expireOldEntries = new Thread(new ThreadStart(ExpireOldEntries)); expireOldEntries.Start(); } }
/// <summary> /// it transfers the existing connection to a new connection without changing the object container /// </summary> /// <param name="container"></param> /// <param name="commandRecieved"></param> /// <param name="serverLost"></param> /// <param name="logs"></param> /// <param name="perfStatsCollector"></param> /// <param name="rspIntegraotr"></param> /// <param name="bindIP"></param> /// <param name="cacheName"></param> /// <param name="ipAddress"></param> /// <param name="cachePort"></param> /// <returns></returns> public bool SwitchTo(Broker container, OnCommandRecieved commandRecieved, OnServerLost serverLost, Logs logs, PerfStatsCollector perfStatsCollector, ResponseIntegrator rspIntegraotr, string bindIP, string cacheName, IPAddress ipAddress, int cachePort) { int oldPort = Port; Initialize(container, commandRecieved, serverLost, logs, perfStatsCollector, rspIntegraotr, bindIP, cacheName); if (this.Connect(Address, cachePort)) { _hostPort = cachePort; this.Port = oldPort; return(true); } return(false); }
public CommandManager(PerfStatsCollector perfStatsCollector) { _perfStatsCollector = perfStatsCollector; bookie = new RequestLogging.Bookie(perfStatsCollector); CommandLogManager.InitializeLogger(perfStatsCollector.InstanceName); CompactFormatterServices.RegisterCompactType(typeof(Web.Synchronization.SyncCache), 124); CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataStructures.StateTransferInfo), 130); CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataStructures.ReplicatorStatusInfo), 131); CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Caching.OperationContext), 153); CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataStructures.EnumerationPointer), 161); CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataStructures.EnumerationDataChunk), 162); }
// For Counters public virtual void IncrementCounter(PerfStatsCollector collector, long value) { }
public DistributedQueue(PerfStatsCollector statsCollector) { _perfStatsCollector = statsCollector; }
internal Connection(Broker container, OnCommandRecieved commandRecieved, OnServerLost serverLost, Logs logs, PerfStatsCollector perfStatsCollector, ResponseIntegrator rspIntegraotr, string bindIP, string cacheName) { Initialize(container, commandRecieved, serverLost, logs, perfStatsCollector, rspIntegraotr, bindIP, cacheName); }
public ServiceCommandManager(PerfStatsCollector perfStatsCollector) : base(perfStatsCollector) { }
private static Cache GetCacheInternal(string cacheName, CacheConnectionOptions cacheConnectionOptions) { if (cacheName == null) { throw new ArgumentNullException("cacheId"); } if (cacheName == string.Empty) { throw new ArgumentException("cacheId cannot be an empty string"); } IsolationLevel mode = cacheConnectionOptions.Mode.Value; string cacheIdWithAlias = cacheName; int maxTries = 2; try { CacheServerConfig config = null; if (mode != IsolationLevel.OutProc) { do { try { config = DirectoryUtil.GetCacheDom(cacheName, null, null, mode == IsolationLevel.InProc); } catch (Exception ex) { if (mode == IsolationLevel.Default) { mode = IsolationLevel.OutProc; } else { throw ex; } } if (config != null) { if (config.CacheType.ToLower().Equals("clustered-cache")) { throw new OperationFailedException(ErrorCodes.CacheInit.CLUSTER_INIT_IN_INPROC, ErrorMessages.GetErrorMessage(ErrorCodes.CacheInit.CLUSTER_INIT_IN_INPROC)); } switch (mode) { case IsolationLevel.InProc: config.InProc = true; break; case IsolationLevel.OutProc: config.InProc = false; break; } } break; } while (maxTries > 0); } lock (typeof(CacheManager)) { Cache primaryCache = null; lock (_cacheCollection) { if (!_cacheCollection.Contains(cacheIdWithAlias)) { CacheImplBase cacheImpl = null; if (config != null && config.InProc) { NCache.Caching.Cache ncache = null; Cache cache = null; maxTries = 2; do { try { CacheConfig cacheConfig = CacheConfig.FromDom(config); cache = new Cache(null, cacheConfig); ncache = CacheFactory.CreateFromPropertyString(cacheConfig.PropertyString, config, null, null, false, false); cacheImpl = new InprocCache(ncache, cacheConfig, cache, null, null); cache.CacheImpl = cacheImpl; if (primaryCache == null) { primaryCache = cache; } else { primaryCache.AddSecondaryInprocInstance(cache); } break; } catch (SecurityException se) { maxTries--; if (maxTries == 0) { throw se; } } } while (maxTries > 0); } else { maxTries = 2; do { try { StatisticsCounter perfStatsCollector; if (ServiceConfiguration.PublishCountersToCacheHost) { perfStatsCollector = new CustomStatsCollector(cacheName, false); ClientConfiguration clientConfig = new ClientConfiguration(cacheName); clientConfig.LoadConfiguration(); perfStatsCollector.StartPublishingCounters(clientConfig.BindIP); } else { perfStatsCollector = new PerfStatsCollector(cacheName, false); } primaryCache = new Cache(null, cacheName, perfStatsCollector); cacheImpl = new RemoteCache(cacheName, primaryCache, cacheConnectionOptions, perfStatsCollector); perfStatsCollector.InitializePerfCounters(false); primaryCache.CacheImpl = cacheImpl; break; } catch (OperationNotSupportedException ex) { throw ex; } } while (maxTries > 0); } if (primaryCache != null) { primaryCache.InitializeCompactFramework(); _cacheCollection.AddCache(cacheIdWithAlias, primaryCache); } } else { lock (_cacheCollection.GetCache(cacheIdWithAlias, false)) { primaryCache = _cacheCollection.GetCache(cacheIdWithAlias, false) as Cache; primaryCache.AddRef(); } } } lock (_cache) { // it is first cache instance. if (_cache.CacheImpl == null) { primaryCache.ExceptionsEnabled = ExceptionsEnabled; _cache = primaryCache; } } return(primaryCache); } } catch (Exception) { throw; } }