Exemplo n.º 1
0
        private void Initialize(Broker container, OnCommandRecieved commandRecieved, OnServerLost serverLost, Logs logs, StatisticsCounter perfStatsCollector, ResponseIntegrator rspIntegraotr, string bindIP, string cacheName)
        {
            _commandRecieved            = null;
            _isConnected                = true;
            _primaryClient              = null;
            _secondaryClient            = null;
            _ipAddress                  = string.Empty;
            _intendedRecipientIPAddress = string.Empty;
            _port                    = 0;
            _connectionMutex         = new object();
            s_receiveBufferSize      = 2048000;
            _processID               = AppUtil.CurrentProcess.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"]);
            }
        }
Exemplo n.º 2
0
        /// <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, StatisticsCounter 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;
                this._serverAddress = new Address(ipAddress, oldPort);
                return(true);
            }

            this.Port           = oldPort;
            this._serverAddress = new Address(ipAddress, oldPort);

            return(false);
        }
Exemplo n.º 3
0
 internal Connection(Broker container, OnCommandRecieved commandRecieved, OnServerLost serverLost, Logs logs, StatisticsCounter perfStatsCollector, ResponseIntegrator rspIntegraotr, string bindIP, string cacheName)
 {
     _connectionStatusLatch = new Latch(ConnectionStatus.Disconnected);
     Initialize(container, commandRecieved, serverLost, logs, perfStatsCollector, rspIntegraotr, bindIP, cacheName);
 }