public override void Execute(RedundancyMode Mode = RedundancyMode.Master) { if (InParameters["EntryItem"].HasValue) { TrackingUnit item = (TrackingUnit)InParameters["EntryItem"].GetValue(); if (item != null) { _ownerStorage.Entry(item); } } }
public void RedundancyModeChange(RedundancyMode mode) { Mode = mode; if (Mode != RedundancyMode.Slave) { StartWork(); } else { StopWork(); } }
public override void Execute(RedundancyMode Mode) { if (InParameters["EntryItem"].HasValue) { TrackingUnit2 item = (TrackingUnit2)InParameters["EntryItem"].GetValue(); if (item != null) { if (item.ID != null && item.ID != string.Empty && item.ID != "") { _ownerStorage.Entry(item); } } } }
public override void Execute(RedundancyMode Mode) { TrackingUnit2 _vehicle = _ownerStorage.Exit(); OutParameters["ExitItem"].SetValue(_vehicle); //if (InParameters["EntryItem"].HasValue) //{ // TrackingUnit item = (TrackingUnit)InParameters["EntryItem"].GetValue(); // if (item != null) // { // _ownerStorage.Entry(item); // } //} }
public override void Execute(RedundancyMode Mode) { try { Int16 subGroupID = (Int16)InParameters["SubGroupID"].GetValue(); TrackingUnit2 item = (TrackingUnit2)InParameters["EntryItem"].GetValue(); _ownerStorage.EntrySubGroup(subGroupID, item); } catch (Exception ex) { LOG.Error(string.Format("执行EntryStorageGroupAction 出错{0}", ex)); } }
public override void Execute(RedundancyMode Mode) { try { Int16 subGroupID = (Int16)InParameters["SubGroupID"].GetValue(); TrackingUnit2 item = _ownerStorage.ExitSubGroup(subGroupID); OutParameters["ExitItem"].SetValue(item); } catch (Exception ex) { LOG.Error(string.Format("执行ExitSubStorageAction 出错{0}", ex)); } }
internal static string ToSerializedValue(this RedundancyMode value) { switch (value) { case RedundancyMode.None: return("None"); case RedundancyMode.Manual: return("Manual"); case RedundancyMode.Failover: return("Failover"); case RedundancyMode.ActiveActive: return("ActiveActive"); case RedundancyMode.GeoRedundant: return("GeoRedundant"); } return(null); }
public static string ToSerialString(this RedundancyMode value) => value switch {
/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param> /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param> /// <param name="formatProvider">not used by this TypeConverter.</param> /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param> /// <returns> /// an instance of <see cref="RedundancyMode" />, or <c>null</c> if there is no suitable conversion. /// </returns> public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => RedundancyMode.CreateFrom(sourceValue);
//private Thread _slaveCheck = null; //private bool IsPartnerModeChange() //{ // if (_lastPartnerMode != PartnerMode) // { // LOG.Debug(string.Format("Redundancy:冗余伙伴的模式从{0}变化成{1}", _lastPartnerMode.ToString(),PartnerMode.ToString())); // _lastPartnerMode = PartnerMode; // return true; // } // else // return false; //} private void RedundancyStatusCheck(object sender) { // 获得对方的模式 if (PartnerAlive) { //LOG.Debug("Redundancy:检测对方正在运行"); PartnerProxy _proxy = (PartnerProxy)_host.GetProxy(); if (_proxy != null) { var result = _proxy.GetPartnerMode(); PartnerMode = (RedundancyMode)(Enum.ToObject(typeof(RedundancyMode), result)); _partnerRunTime = _proxy.GetPartnerRunTime(); //LOG.Debug(string.Format("RedundancyClient:冗余伙伴的模式为:{0}", PartnerMode.ToString())); } //模式比较 if (Mode == RedundancyMode.Master) { if (PartnerMode == RedundancyMode.Master) { if (!WeAreFirstRun()) {//对方先运行 Log.Debug("Redundancy主从切换原因:双方Master,对方先启动"); ChangeMode(RedundancyMode.Slave); } } } else if (Mode == RedundancyMode.Slave) { if (PartnerMode == RedundancyMode.Slave) { if (WeAreFirstRun()) {//我方先运行 Log.Debug("Redundancy主从切换原因:对方Slave,我方Slave,我方先启动"); ChangeMode(RedundancyMode.Master); } } } else if (Mode == RedundancyMode.Unknown) { if (PartnerMode == RedundancyMode.Master) { Log.Debug("Redundancy主从切换原因:对方Master,我方是Unknown"); ChangeMode(RedundancyMode.Slave); } else if (PartnerMode == RedundancyMode.Slave) { Log.Debug("Redundancy主从切换原因对方Slave,我方是Unknown"); ChangeMode(RedundancyMode.Master); } else if (PartnerMode == RedundancyMode.Unknown) { if (WeAreFirstRun()) {//我方先运行 Log.Debug("Redundancy主从切换原因对方Unknown,我方是Unknown,我方先启动"); ChangeMode(RedundancyMode.Master); } } } PartnerUnliveCounts = 0; } else { // 连接断开 PartnerMode = RedundancyMode.Unknown; if (Mode != RedundancyMode.Master) { if (PartnerUnliveCounts >= ConfirmPartnerUnliveLimitation) { PartnerUnliveCounts = 0; Log.Debug("Redundancy主从切换原因:对方不在线,已经过了验证期"); ChangeMode(RedundancyMode.Master); } else { Log.Debug(string.Format("Redundancy:对方不在线,验证{0}次", PartnerUnliveCounts)); PartnerUnliveCounts++; } } } }
public void ChangeMode(RedundancyMode mode) { if (mode == Mode) { //没有变化 return; } // 有变化 Log.Debug($"主从模式从{Mode}切换成{mode}"); Mode = mode; // 通知所有资源对象 //先启动Machine资源 sunjian 2020-3-2 foreach (var resource in ResourceManager.GetAllResources()) { if (!(resource is IRedundancy res)) { continue; } if (resource.ResourceType != "Machine") { continue; } if (res.CurrentRedundancyMode != mode) { res.RedundancyModeChange(mode); } } //启动非Machine和非Process的资源 sunjian 2020-3-2 foreach (var resource in ResourceManager.GetAllResources()) { if (!(resource is IRedundancy res)) { continue; } if (resource.ResourceType == "Machine" || resource.ResourceType == "Process") { continue; } if (res.CurrentRedundancyMode != mode) { res.RedundancyModeChange(mode); } } //最后启动非Machine和非Process的资源 sunjian 2020-3-2 foreach (var resource in ResourceManager.GetAllResources()) { if (!(resource is IRedundancy res)) { continue; } if (resource.ResourceType != "Process") { continue; } if (res.CurrentRedundancyMode != mode) { res.RedundancyModeChange(mode); } } if (mode == RedundancyMode.Master) { StartSync(); //启动同步 } else { StopSync(); //关闭同步 } }
/// <summary> /// 设置规约冗余模式。 /// </summary> /// <param name="redundancy">给定的冗余模式。</param> /// <returns>返回 <see cref="IAccessorSpecification"/>。</returns> public IAccessorSpecification SetRedundancy(RedundancyMode redundancy) { Redundancy = redundancy; return(this); }
public void RedundancyModeChange(RedundancyMode mode) { _mode = mode; }
public override void Execute(RedundancyMode Mode) { //string jsonStroage = _ownerStorage.ToJson(); //OutParameters["StorageJson"].SetValue(jsonStroage); throw new Exception("没有ToJson方法"); }
/// <summary> /// 获取可冗余的存取器集合。 /// </summary> /// <param name="accessors">给定的 <see cref="IEnumerable{IAccessor}"/>。</param> /// <param name="mode">给定的 <see cref="RedundancyMode"/>。</param> /// <returns>返回经过冗余处理后的存取器。</returns> public static IAccessor GetRedundableAccessors(this IEnumerable <IAccessor> accessors, RedundancyMode mode) { if (mode == RedundancyMode.Mirroring) { return(new MirroringAccessors(accessors)); } return(new StripingAccessors(accessors)); }
public override void Execute(RedundancyMode Mode = RedundancyMode.Master) { string jsonStroage = _ownerStorage.ToJson(); OutParameters["StorageJson"].SetValue(jsonStroage); }