public void UpdateConnection(ConnectionTable.Connection newCon)
 {
     lock (senderList.SyncRoot)
     {
         foreach (DedicatedMessageSender dmSender in senderList)
         {
             dmSender.UpdateConnection(newCon);
         }
     }
 }
        public void AddDedicatedSenderThread(ConnectionTable.Connection connection, bool onPrimaryNIC, bool doNaggling, int nagglingSize)
        {

            DedicatedMessageSender dmSender = new DedicatedMessageSender(mq, connection, sync_lock, _ncacheLog, onPrimaryNIC, doNaggling, nagglingSize);

            dmSender.Start();
            lock (senderList.SyncRoot)
            {
                senderList.Add(dmSender);
            }

        }
        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];
        }
 public void UpdateConnection(ConnectionTable.Connection newCon)
 {
     peerConnection = newCon;
 }
示例#5
0
 private void InitBlock(ConnectionTable enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
示例#6
0
 internal Reaper(ConnectionTable enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
示例#7
0
 public virtual void addConnectionListener(ConnectionTable.ConnectionListener l)
 {
     if (l != null && !conn_listeners.Contains(l))
         conn_listeners.Add(l);
 }
示例#8
0
 public virtual void removeConnectionListener(ConnectionTable.ConnectionListener l)
 {
     if (l != null)
         conn_listeners.Remove(l);
 }
示例#9
0
        /// <summary> ConnectionTable including a connection reaper. Connections that have been idle for more than conn_expire_time
        /// milliseconds will be closed and removed from the connection table. On next access they will be re-created.
        /// 
        /// </summary>
        /// <param name="srv_port">The port on which the server will listen.If this port is reserved, the next
        /// free port will be taken (incrementing srv_port).
        /// </param>
        /// <param name="bind_addr">The host name or IP address of the interface to which the server socket will bind.
        /// This is interesting only in multi-homed systems. If bind_addr is null, the
        /// server socket will bind to the first available interface (e.g. /dev/hme0 on
        /// Solaris or /dev/eth0 on Linux systems).
        /// </param>
        /// <param name="srv_port">The port to which the server socket will bind to. If this port is reserved, the next
        /// free port will be taken (incrementing srv_port).
        /// </param>
        /// <param name="reaper_interval">Number of milliseconds to wait for reaper between attepts to reap idle connections
        /// </param>
        /// <param name="conn_expire_time">Number of milliseconds a connection can be idle (no traffic sent or received until
        /// it will be reaped
        /// </param>
        /// 

        public ConnectionTable(ConnectionTable.Receiver r, System.Net.IPAddress bind_addr, int srv_port, long reaper_interval, long conn_expire_time, ILogger NCacheLog)
        {
            setReceiver(r);
            this.bind_addr1 = bind_addr;
            this.srv_port = srv_port;
            this.reaper_interval = reaper_interval;
            this.conn_expire_time = conn_expire_time;
            this._ncacheLog = NCacheLog;
            start();
        }
示例#10
0
 public virtual void setReceiver(ConnectionTable.Receiver r)
 {
     receiver = r;
 }
示例#11
0
        /// <summary> Create a ConnectionTable</summary>
        /// <param name="r">A reference to a receiver of all messages received by this class. Method <code>receive()</code>
        /// will be called.
        /// </param>
        /// <param name="bind_addr">The host name or IP address of the interface to which the server socket will bind.
        /// This is interesting only in multi-homed systems. If bind_addr is null, the
        /// server socket will bind to the first available interface (e.g. /dev/hme0 on
        /// Solaris or /dev/eth0 on Linux systems).
        /// </param>
        /// <param name="srv_port">The port to which the server socket will bind to. If this port is reserved, the next
        /// free port will be taken (incrementing srv_port).
        /// </param>
        /// 

        public ConnectionTable(ConnectionTable.Receiver r, System.Net.IPAddress bind_addr1, System.Net.IPAddress bind_addr2, int srv_port, int port_range, ILogger NCacheLog, int retries, int retryInterval)
        {
            setReceiver(r);
            enclosingInstance = (TCP)r;
            this.bind_addr1 = bind_addr1;

            this.bind_addr2 = bind_addr2;

            this.srv_port = srv_port;

            this.port_range = port_range;

            this._ncacheLog = NCacheLog;

            this._retries = retries;
            this._retryInterval = retryInterval;

            start();
        }
示例#12
0
            internal Connection(ConnectionTable enclosingInstance, System.Net.Sockets.Socket s, Address peer_addr, ILogger NCacheLog, bool isPrimary, int naglingSize, int retries, int retryInterval)
            {
                InitBlock(enclosingInstance);
                sock = s;
                this.peer_addr = peer_addr;

                this._retries = retries;
                this._retryInterval = retryInterval;

                this._ncacheLog = NCacheLog;

                _isPrimary = isPrimary;

                if (naglingSize > receiveBufferSize)
                    receiveBuffer = new byte[naglingSize + 8];
                else
                    receiveBuffer = new byte[receiveBufferSize];
            }
示例#13
0
文件: TCP.cs 项目: javithalion/NCache
        /// <param name="">ri
        /// </param>
        /// <param name="">cet
        /// </param>
        /// <param name="">b_addr
        /// </param>
        /// <param name="">s_port
        /// </param>
        /// <throws>  Exception </throws>
        /// <returns> ConnectionTable
        /// Sub classes overrides this method to initialize a different version of
        /// ConnectionTable.
        /// </returns>
        /// 

        protected internal virtual ConnectionTable getConnectionTable(long ri, long cet, System.Net.IPAddress b_addr1, System.Net.IPAddress b_addr2, int s_port, int retries, int retryInterval)

        {
            ConnectionTable cTable = null;

            if (ri == 0 && cet == 0)
            {
                cTable = new ConnectionTable(this, b_addr1, bind_addr2, start_port, port_range, stack.NCacheLog, retries, retryInterval);
            }
            else
            {
                if (ri == 0)
                {
                    ri = 5000;
                    Stack.NCacheLog.Info("reaper_interval was 0, set it to " + ri);
                }
                if (cet == 0)
                {
                    cet = 1000 * 60 * 5;
                    Stack.NCacheLog.Info("conn_expire_time was 0, set it to " + cet);
                }
                cTable = new ConnectionTable(this, b_addr1, s_port, ri, cet, this.Stack.NCacheLog);
            }

            return cTable;
        }
示例#14
0
文件: TCP.cs 项目: javithalion/NCache
        public override void start()
        {
            // Incase of TCP stack we'll get a reference to TOTAL, which is the top
            // protocol in our case.
            upper = Stack.findProtocol("TOTAL");

            ct = getConnectionTable(reaper_interval, conn_expire_time, bind_addr1, bind_addr2, start_port, _retries, _retryInterval);

            
            ct.addConnectionListener(this);
            ct.ReceiveBufferSize = recv_buf_size;
            ct.SendBufferSize = send_buf_size;
            local_addr = ct.LocalAddress;
            if (additional_data != null /*&& local_addr is Address*/)
                ((Address)local_addr).AdditionalData = additional_data;
            passUp(new Event(Event.SET_LOCAL_ADDRESS, local_addr, Priority.Critical));
            _asyncProcessor = new AsyncProcessor(stack.NCacheLog);
            _asyncProcessor.Start();

            _keepAlive = new ConnectionKeepAlive(this, ct, _heartBeatInterval);
            if (_useKeepAlive)
                _keepAlive.Start();


            Stack.NCacheLog.CriticalInfo("TCP.start", "operating parameters -> [ heart_beat:" + _useKeepAlive + " ;heart_beat_interval: " + _heartBeatInterval + " ;async_up_deliver: " + asyncPassup + " ;connection_retries: " + _retries + " ;connection_retry_interval: " + _retryInterval + " ]");
            
        }
示例#15
0
文件: TCP.cs 项目: javithalion/NCache
 public ConnectionKeepAlive(TCP enclosingInsatnce, ConnectionTable connectionTable, int interval)
 {
     _enclosingInstance = enclosingInsatnce;
     _ct = connectionTable;
     _interval = interval;
 }