Esempio n. 1
0
 public UpHandler(Alachisoft.NCache.Common.DataStructures.Queue mq, Protocol handler, string name, int id)
 {
     this.mq = mq;
     this.handler = handler;
     if(name != null)
         Name = name;
     IsBackground = true;
     this.id = id;
 }
Esempio n. 2
0
		public virtual void  stopProtocolStack(Protocol start_prot)
		{
			while (start_prot != null)
			{
				start_prot.stopInternal();
				start_prot.destroy();
				start_prot = start_prot.DownProtocol;
			}
		}
Esempio n. 3
0
		public virtual void  startProtocolStack(Protocol bottom_prot)
		{
			while (bottom_prot != null)
			{
				bottom_prot.startDownHandler();
				bottom_prot.startUpHandler();
				bottom_prot = bottom_prot.UpProtocol;
			}
		}
Esempio n. 4
0
            public UpHandler(Alachisoft.NCache.Common.DataStructures.Queue mq, Protocol handler)
			{
				this.mq = mq;
				this.handler = handler;
				if (handler != null)
				{
					Name = "UpHandler (" + handler.Name + ')';
				}
				else
				{
					Name = "UpHandler";
				}
				IsBackground = true;
			}
Esempio n. 5
0
		/// <summary> This constructor whould be used when we want AckSenderWindow to send the message added
		/// by add(), rather then ourselves.
		/// </summary>
        public AckSenderWindow(AckSenderWindow.RetransmitCommand com, long[] interval, Protocol transport, ILogger NCacheLog)
		{
            //this.nTrace = nTrace;
            _ncacheLog = NCacheLog;
            InitBlock();
			retransmit_command = com;
			this.interval = interval;
			this.transport = transport;
			retransmitter.RetransmitTimeouts = interval;
		}
Esempio n. 6
0
        public override void stop()
        {
            isClosing = true;
            local_addr = null;
            if (_asyncProcessor != null)
                _asyncProcessor.Stop();
            _asyncProcessor = null;

            if (_keepAlive != null) _keepAlive.Stop();

            ct.stop();
            upper = null;
        }
Esempio n. 7
0
        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 + " ]");
            
        }
Esempio n. 8
0
        /// <summary> Handle the stop() method travelling down the stack.
        /// <p>
        /// The local addr is set to null, since after a Start->Stop->Start
        /// sequence this member's addr is not guaranteed to be the same
        /// 
        /// </summary>
        public override void stop()
        {
            // *** Get an exclusive lock
            try
            {
                stateLock.AcquireWriterLock(Timeout.Infinite);
                try
                {
                    state = NULL_STATE;
                    retransmitter.reset();
                    _mcastRetransmitter.reset();
                    reqTbl.Clear();
                    upTbl.Clear();
                    addr = null;


                    // *** Revoke the exclusive lock
                }
                finally
                {
                    stateLock.ReleaseWriterLock();
                    transport = null;
                }
            }
            catch (ThreadInterruptedException ex)
            {
                Stack.NCacheLog.Error("Protocols.TOTAL.stop", ex.ToString());
            }
        }
Esempio n. 9
0
        /// <summary> Prepare this layer to receive messages from above</summary>
        public override void start()
        {
            TimeScheduler timer;

            // Incase of TCP stack we'll get a reference to TCP, which is the transport
            // protocol in our case. For udp stack we'll fail.
            transport = Stack.findProtocol("TCP");

            

            reqTbl = Hashtable.Synchronized(new Hashtable());
            upTbl = Hashtable.Synchronized(new Hashtable());

            //======================================================
            _mcastReqTbl = Hashtable.Synchronized(new Hashtable());
            _mcastUpTbl = Hashtable.Synchronized(new Hashtable());
            //======================================================

            
            retransmitter = new AckSenderWindow(new Command(this), AVG_RETRANSMIT_INTERVAL, stack.NCacheLog);
            _mcastRetransmitter = new AckSenderWindow(new MCastCommand(this), AVG_MCAST_RETRANSMIT_INTERVAL, stack.NCacheLog);
        }
Esempio n. 10
0
		public override void  destroy()
		{
			if (top_prot != null)
			{
				conf.stopProtocolStack(top_prot); // destroys msg queues and threads

                if (perfStatsColl != null) perfStatsColl.Dispose();

				top_prot = null;
			}
		}
Esempio n. 11
0
		/// <summary> Inserts an already created (and initialized) protocol into the protocol list. Sets the links
		/// to the protocols above and below correctly and adjusts the linked list of protocols accordingly.
		/// Note that this method may change the value of top_prot or bottom_prot.
		/// </summary>
		/// <param name="prot">The protocol to be inserted. Before insertion, a sanity check will ensure that none
		/// of the existing protocols have the same name as the new protocol.
		/// </param>
		/// <param name="position">Where to place the protocol with respect to the neighbor_prot (ABOVE, BELOW)
		/// </param>
		/// <param name="neighbor_prot">The name of the neighbor protocol. An exception will be thrown if this name
		/// is not found
		/// </param>
		/// <exception cref=""> Exception Will be thrown when the new protocol cannot be created, or inserted.
		/// </exception>
		public virtual void  insertProtocol(Protocol prot, int position, string neighbor_prot)
		{
			conf.insertProtocol(prot, position, neighbor_prot, this);
		}
Esempio n. 12
0
		public virtual void  setup()
		{
			if (top_prot == null)
			{
				top_prot = conf.setupProtocolStack(setup_string, this);
				if (top_prot == null)
					throw new System.Exception("ProtocolStack.setup(): couldn't create protocol stack");
				top_prot.UpProtocol = this;
				bottom_prot = conf.getBottommostProtocol(top_prot);
				conf.startProtocolStack(bottom_prot); // sets up queues and threads
			}
		}
Esempio n. 13
0
		public virtual Protocol findProtocol(Protocol prot_stack, string name)
		{
			string s;
			Protocol curr_prot = prot_stack;
			
			while (true)
			{
				s = curr_prot.Name;
				if (s == null)
					continue;
				if (s.Equals(name))
					return curr_prot;
				curr_prot = curr_prot.DownProtocol;
				if (curr_prot == null)
					break;
			}
			return null;
		}
Esempio n. 14
0
		/// <summary> Inserts an already created (and initialized) protocol into the protocol list. Sets the links
		/// to the protocols above and below correctly and adjusts the linked list of protocols accordingly.
		/// </summary>
		/// <param name="prot"> The protocol to be inserted. Before insertion, a sanity check will ensure that none
		/// of the existing protocols have the same name as the new protocol.
		/// </param>
		/// <param name="position">Where to place the protocol with respect to the neighbor_prot (ABOVE, BELOW)
		/// </param>
		/// <param name="neighbor_prot">The name of the neighbor protocol. An exception will be thrown if this name
		/// is not found
		/// </param>
		/// <param name="stack">The protocol stack
		/// </param>
		/// <exception cref=""> Exception Will be thrown when the new protocol cannot be created, or inserted.
		/// </exception>
		public virtual void  insertProtocol(Protocol prot, int position, string neighbor_prot, ProtocolStack stack)
		{
			if (neighbor_prot == null)
				throw new System.Exception("Configurator.insertProtocol(): neighbor_prot is null");
			if (position != ProtocolStack.ABOVE && position != ProtocolStack.BELOW)
				throw new System.Exception("Configurator.insertProtocol(): position has to be ABOVE or BELOW");
			
			
			// find the neighbors below and above
			
			
			
			// connect to the protocol layer below and above
		}
Esempio n. 15
0
		public virtual Protocol getBottommostProtocol(Protocol prot_stack)
		{
			Protocol tmp = null, curr_prot = prot_stack;
			
			while (true)
			{
				if ((tmp = curr_prot.DownProtocol) == null)
					break;
				curr_prot = tmp;
			}
			return curr_prot;
		}