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; }
public virtual void stopProtocolStack(Protocol start_prot) { while (start_prot != null) { start_prot.stopInternal(); start_prot.destroy(); start_prot = start_prot.DownProtocol; } }
public virtual void startProtocolStack(Protocol bottom_prot) { while (bottom_prot != null) { bottom_prot.startDownHandler(); bottom_prot.startUpHandler(); bottom_prot = bottom_prot.UpProtocol; } }
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; }
/// <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; }
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; }
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 + " ]"); }
/// <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()); } }
/// <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); }
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; } }
/// <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); }
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 } }
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; }
/// <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 }
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; }