Beispiel #1
0
        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"]);
            }
        }
Beispiel #2
0
        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"]);
            }
        }
Beispiel #3
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,
                             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);
        }
Beispiel #4
0
        internal Connection(OnCommandRecieved commandRecieved, OnServerLost serverLost, Logs logs, PerfStatsCollector perfStatsCollector,ResponseIntegrator rspIntegraotr, string bindIP)
        {
            _commandRecieved = commandRecieved;
            _serverLost = serverLost;
            _logger = logs;
            _responseIntegrator = rspIntegraotr;

            _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"]);
        }
Beispiel #5
0
 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);
 }
Beispiel #6
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);
 }
Beispiel #7
0
        private Broker(RemoteCache cache, bool importHashMap, PerfStatsCollector2 perfStatsColl,
            CacheInitParams initParams)
        {
            _bulkEventCallback = new WaitCallback(RaiseBulkEvent);
            this._clientConfig = new ClientConfiguration(cache.CacheId, initParams);
            this._cache = cache;
            this._balanceNode = _clientConfig.BalanceNodes;
            this._importHashmap = _clientConfig.ImportHashmap;

            this._operationTimeout = _clientConfig.Timeout;
            this._connectionTimeout = _clientConfig.ConnectionTimeout;
            this._connectionRetries = _clientConfig.ConnectionRetries;
            this._retryInterval = _clientConfig.RetryInterval;

            this._retryConnnectionDelay = _clientConfig.RetryConnectionDelay;
            this._retryConnectionDelayInMinutes = Convert.ToDouble(_retryConnnectionDelay)/60000;
                //Conversion to minutes from milliseconds;
            _perfStatsColl2 = perfStatsColl;

            int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
            string instanceName = "Client." + cache.CacheId + "." + pid;

            if (_perfStatsColl == null || !_perfStatsColl.InstanceName.Equals(instanceName))
            {
                _perfStatsColl = new PerfStatsCollector(instanceName, 0);
            }

            this._commandReieved = new OnCommandRecieved(CommandReceived);
            this._serverLost = new OnServerLost(ServerLost);
            this._requestTable = Hashtable.Synchronized(new Hashtable(10000, 0.75f));
            this._pool = new ConnectionPool();
        }