/// <summary> /// Constructor /// </summary> /// <param name="parent"></param> public StateTransferTask(ReplicatedServerCache parent) { _parent = parent; _ncacheLog = parent.Context.NCacheLog; _promise = new Promise(); }
/// <summary> /// Constructor /// </summary> /// <param name="parent"></param> public StateTransferTask(ClusterCacheBase parent, Address localAdd) { _parent = parent; _promise = new Promise(); _localAddress = localAdd; if (!string.IsNullOrEmpty(System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.StateTransferDataSizePerSecond"])) { try { float result = 0; float.TryParse(System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.StateTransferDataSizePerSecond"], out result); if (result > 0) stateTxfrDataSizePerSecond = (long)(result * MB); } catch (Exception e) { _parent.NCacheLog.Error(this.Name, "Invalid value specified for NCacheServer.StateTransferDataSizePerSecond." + System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.StateTransferDataSizePerSecond"]); } } if (!string.IsNullOrEmpty(System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.EnableGCDuringStateTransfer"])) { try { bool enabled = false; if (bool.TryParse(System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.EnableGCDuringStateTransfer"], out enabled)) _enableGc = enabled; } catch (Exception e) { _parent.NCacheLog.Error(this.Name, "Invalid value specified for NCacheServer.EnableGCDuringStateTransfer." + System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.EnableGCDuringStateTransfer"]); } } if (!string.IsNullOrEmpty(System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.GCThreshold"])) { try { long threshold = _gcThreshhold; if (long.TryParse(System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.GCThreshold"], out threshold)) _gcThreshhold = threshold * MB; } catch (Exception e) { _parent.NCacheLog.Error(this.Name, "Invalid value specified for NCacheServer.GCThreshold." + System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.GCThreshold"]); } } if (_parent != null && _parent.NCacheLog.IsErrorEnabled) _parent.NCacheLog.CriticalInfo(Name, " explicit-gc-enabled =" + _enableGc + " threshold = " + _gcThreshhold); }
/// <summary> Iterates through all the protocols <em>from top to bottom</em> and does the following: /// <ol> /// <li>Waits until all messages in the down queue have been flushed (ie., size is 0) /// <li>Calls stop() on the protocol /// </ol> /// </summary> public virtual void stopStack() { if (timer != null) { try { timer.Dispose(); } catch (System.Exception ex) { NCacheLog.Error("ProtocolStack.stopStack", "exception=" + ex); } } if (stopped) return ; if (stop_promise == null) stop_promise = new Promise(); else stop_promise.Reset(); down(new Event(Event.STOP)); stop_promise.WaitResult(5000); operational = false; stopped = true; }
/// <summary> /// Constructor /// </summary> protected StateTransferTask() { _promise = new Promise(); }
/// <summary> Start all layers. The {@link Protocol#start()} method is called in each protocol, /// <em>from top to bottom</em>. /// Each layer can perform some initialization, e.g. create a multicast socket /// </summary> public virtual void startStack() { object start_result = null; if (stopped == false) return ; timer.Start(); if (start_promise == null) start_promise = new Promise(); else start_promise.Reset(); down(new Event(Event.START)); start_result = start_promise.WaitResult(0); if (start_result != null && start_result is System.Exception) { if (start_result is System.Exception) throw (System.Exception) start_result; else { throw new System.Exception("ProtocolStack.start(): exception is " + start_result); } } stopped = false; }