/// <summary> /// 初始化属于指定服务角色的系统工作者 /// </summary> /// <param name="role">服务角色</param> /// <param name="useRemoteConfig">是否使用远程配置的标示</param> /// <param name="setting">远程配置设置</param> /// <param name="notificationHandler">异常通知处理器</param> /// <param name="csnAddress">远程CSN的IP地址</param> /// <exception cref="ArgumentNullException">参数不能为空</exception> public void Initialize(string role, bool useRemoteConfig, RemoteConfigurationSetting setting, ITracingNotificationHandler notificationHandler = null, string csnAddress = null) { if (string.IsNullOrEmpty(role)) { throw new ArgumentNullException("role"); } if (useRemoteConfig && setting == null) { throw new ArgumentNullException("setting"); } if (IsInitialized) { return; } _configurationProxy = (!useRemoteConfig ? (IRemoteConfigurationProxy) new RemoteConfigurationProxy(csnAddress) : new SolitaryRemoteConfigurationProxy(csnAddress)); //Regist("LGS", new LGSProtocolStack()); //TracingManager.NotificationHandler = notificationHandler ?? new RemoteLogProxy(); Role = role; FixedTypeManager.Add(typeof(Color), 6); FixedTypeManager.Add(typeof(MessageIdentity), 5); FixedTypeManager.Add(typeof(TransactionIdentity), 18); IntellectTypeProcessorMapping.Instance.Regist(new MessageIdentityProcessor()); IntellectTypeProcessorMapping.Instance.Regist(new TransactionIdentityProcessor()); IntellectTypeProcessorMapping.Instance.Regist(new ColorIntellectPropertyProcessor()); ExtensionTypeMapping.Regist(typeof(MessageIdentityValueStored)); ExtensionTypeMapping.Regist(typeof(TransactionIdentityValueStored)); //config remote configuration loader. if (useRemoteConfig) { KJFramework.Configurations.Configurations.RemoteConfigLoader = new RemoteConfigurationLoader(setting); } //initialize long...long memory buffer for tcp layer. ChannelConst.Initialize(); CommonCounter.Instance.Initialize(); // Init CSN Dictionary <string, int> maxRanges = new Dictionary <string, int>(); Dictionary <string, ServiceCoreConfig[]> addresses = new Dictionary <string, ServiceCoreConfig[]>(); InitCSN(addresses, maxRanges); _transactionManager = new MessageTransactionManager(new TransactionIdentityComparer()); _metadataTransactionManager = new MetadataTransactionManager(new TransactionIdentityComparer()); _clsuter = HashNetworkCluster.Create(_transactionManager, new IntellectObjectSystemConnectionPool(), addresses, maxRanges); _metadataCluster = MetadataContainerHashNetworkCluster.Create(_metadataTransactionManager, new MetadataSystemConnectionPool(), addresses, maxRanges); _syncProxy = new RemoteDataSyncProxy(); _isInitialized = true; }
/// <summary> /// 初始化属于指定服务角色的系统工作者 /// </summary> /// <param name="role">服务角色</param> /// <param name="setting">远程配置设置</param> /// <param name="configurationProxy">远程配置站访问代理器</param> /// <param name="notificationHandler">异常通知处理器</param> /// <param name="proxy">KAE资源代理器</param> /// <exception cref="ArgumentNullException">参数不能为空</exception> public static void Initialize(string role, RemoteConfigurationSetting setting, IRemoteConfigurationProxy configurationProxy, ITracingNotificationHandler notificationHandler = null, IKAEResourceProxy proxy = null) { if (IsInitialized) { return; } if (setting == null) { setting = RemoteConfigurationSetting.Default; } if (proxy == null) { proxy = new KAEHostResourceProxy(); } if (string.IsNullOrEmpty(role)) { throw new ArgumentNullException(nameof(role)); } if (configurationProxy == null) { throw new ArgumentNullException(nameof(configurationProxy)); } SystemConfigurations.Initialize(role, setting, configurationProxy); _tracing = TracingManager.GetTracing(typeof(SystemWorker));; TransactionGlobal.Initialize(); _configurationProxy = configurationProxy; _hostProxy = proxy; TracingManager.NotificationHandler = notificationHandler ?? new RemoteLogProxy(); InitializeCore(role); //initialize long...long memory buffer for tcp layer. ChannelConst.Initialize(); _isInitialized = true; IsInSpecifiedKPP = false; }
/// <summary> /// 初始化属于指定服务角色的系统工作者 /// <para>* 当使用此方法,并传递useRemoteConfig=true时,此方法内部将使用默认的远程配置设置</para> /// </summary> /// <param name="role">服务角色</param> /// <param name="useRemoteConfig">是否使用远程配置的标示</param> /// <param name="notificationHandler">异常通知处理器</param> /// <param name="csnAddress">远程CSN的IP地址</param> public void Initialize(string role, bool useRemoteConfig = false, ITracingNotificationHandler notificationHandler = null, string csnAddress = null) { Initialize(role, useRemoteConfig, RemoteConfigurationSetting.Default, notificationHandler, csnAddress ?? ConfigurationManager.AppSettings["CSN"]); }