/// <summary> /// Initializes the <see cref="ComponentTestManager"/>, gets the <see cref="RelayNodeConfig"/> /// and Initializes the forwarder. /// </summary> /// <param name="createTransports">Optional, creates other /// <see cref="IRelayTransport"/>s to be added to the transports.</param> public void Initialize(params CreateTransportDelegate[] createTransports) { _createTransports = createTransports; TransportFactory.CreateTransportMethod = _createTransportDelegate; _forwarder = new Forwarder(); //we initialize because there's a static singleton we're wanting to get set. RelayNodeConfig config = RelayNodeConfig.GetRelayNodeConfig(); if (config == null) { throw new InvalidOperationException("RelayNodeConfig not found."); } if (config.TransportSettings != null && config.TransportSettings.ListenPort != 0) { //do we fix for them? throw new InvalidOperationException("TransportSettings.ListenPort must be zero to make forwarder act like a client."); } _config = config; _forwarder.Initialize(config, null); }
/// <summary> /// Initializes the reload config. /// </summary> /// <param name="config">The config.</param> /// <param name="isInit">if set to <c>true</c> [is init].</param> internal void InitializeReloadConfig(RelayNodeConfig config, bool isInit) { #region Set Component Configs if (config == null) { Exception ex = new Exception("Unable to Initialize/Reload Config for CacheIndexV3Store because RelayNodeConfig is null"); LoggingUtil.Log.Error(ex.Message); throw ex; } Interlocked.Exchange(ref nodeConfig, config); Interlocked.Exchange(ref storageConfiguration, InitializeConfig(nodeConfig)); #endregion #region Setup Forwarder if (ForwarderComponent == null) { ForwarderComponent = new Forwarder(); ForwarderComponent.Initialize(config, null); } else { ForwarderComponent.ReloadConfig(config); } #endregion #region Init/Reload Component if (IndexStorageComponent == null) { IndexStorageComponent = InitializeStorageComponent(storageConfiguration.BerkeleyDbConfig); } else { ReloadStorageComponent(storageConfiguration.BerkeleyDbConfig, IndexStorageComponent); } #endregion #region init memoryPool if (this.myMemoryPool == null) { this.myMemoryPool = new MemoryStreamPool( storageConfiguration.CacheIndexV3StorageConfig.MemPoolItemInitialSizeInBytes, ResourcePool.ResourcePool <MemoryStream> .InfiniteReuse, storageConfiguration.CacheIndexV3StorageConfig.MemPoolMinItemNumber); } #region init DataMembers Interlocked.Exchange(ref relatedTypeIds, InitializeRelatedTypeIds(nodeConfig)); Interlocked.Exchange(ref compressOptions, InitializeCompressOptions(nodeConfig)); InitializeClusterInfo(out myClusterPosition, out numClustersInGroup, out myZone); LockingUtil.Instance.InitializeLockerObjects(storageConfiguration.CacheIndexV3StorageConfig.LockMultiplier, numClustersInGroup); LegacySerializationUtil.Instance.InitializeLegacySerializtionTypes(nodeConfig.TypeSettings, storageConfiguration.CacheIndexV3StorageConfig.SupportLegacySerialization); #region init performance counters List <short> typeIdList = new List <short>(); foreach (IndexTypeMapping indexTypeMapping in storageConfiguration.CacheIndexV3StorageConfig.IndexTypeMappingCollection) { typeIdList.Add(indexTypeMapping.TypeId); } // get the max type id short maxTypeId = config.TypeSettings.MaxTypeId; // initialize or re-initialize performance counters, // counter category will also be created if it is not there PerformanceCounters.Instance.InitializeCounters( config.TransportSettings.ListenPort, typeIdList, maxTypeId, isInit); #endregion #region Set HashCollections Interlocked.Exchange(ref tagHashCollection, InitializeTagHashCollection(storageConfiguration)); Interlocked.Exchange(ref stringHashCollection, InitializeStringHashCollection(storageConfiguration)); #endregion #endregion #region Init Domain Specific Config DomainSpecificConfig = new DomainSpecificConfig { StreamRecencyConfig = ConfigurationManager.GetSection("StreamRecencyConfig") as StreamRecencyConfig }; #endregion }
/// <summary> /// Initializes the reload config. /// </summary> /// <param name="config">The config.</param> /// <param name="isInit">if set to <c>true</c> [is init].</param> internal void InitializeReloadConfig(RelayNodeConfig config, bool isInit) { #region Set Component Configs if (config == null) { Exception ex = new Exception("Unable to Initialize/Reload Config for CacheIndexV3Store because RelayNodeConfig is null"); LoggingUtil.Log.Error(ex.Message); throw ex; } Interlocked.Exchange(ref nodeConfig, config); Interlocked.Exchange(ref storageConfiguration, InitializeConfig(nodeConfig)); #endregion #region Setup Forwarder if (ForwarderComponent == null) { ForwarderComponent = new Forwarder(); ForwarderComponent.Initialize(config, null); } else { ForwarderComponent.ReloadConfig(config); } #endregion #region Init/Reload Component if (IndexStorageComponent == null) { IndexStorageComponent = InitializeStorageComponent(storageConfiguration.BerkeleyDbConfig); } else { ReloadStorageComponent(storageConfiguration.BerkeleyDbConfig, IndexStorageComponent); } #endregion #region init DataMembers Interlocked.Exchange(ref relatedTypeIds, InitializeRelatedTypeIds(nodeConfig)); Interlocked.Exchange(ref compressOptions, InitializeCompressOptions(nodeConfig)); InitializeClusterInfo(out myClusterPosition, out numClustersInGroup, out myZone); LockingUtil.Instance.InitializeLockerObjects(storageConfiguration.CacheIndexV3StorageConfig.LockMultiplier, numClustersInGroup); LegacySerializationUtil.Instance.InitializeLegacySerializtionTypes(nodeConfig.TypeSettings, storageConfiguration.CacheIndexV3StorageConfig.SupportLegacySerialization); List <short> typeIdList = new List <short>(); #region Index Capping Check // Index Capping feature for multiple indexes not supported // TBD - Remove this check when feature is supported foreach (IndexTypeMapping indexTypeMapping in storageConfiguration.CacheIndexV3StorageConfig.IndexTypeMappingCollection) { typeIdList.Add(indexTypeMapping.TypeId); if (indexTypeMapping.IndexCollection.Count > 1 && indexTypeMapping.IndexServerMode == IndexServerMode.Databound) { foreach (Index indexInfo in indexTypeMapping.IndexCollection) { if (indexInfo.MaxIndexSize > 0) { LoggingUtil.Log.ErrorFormat("TypeId {0} -- Index Capping feature for multiple indexes not supported", indexTypeMapping.TypeId); throw new Exception("Index Capping feature for multiple indexes not supported"); } } } } #endregion #region init performance counters // get the max type id short maxTypeId = config.TypeSettings.MaxTypeId; // initialize or re-initialize performance counters, // counter category will also be created if it is not there PerformanceCounters.Instance.InitializeCounters( config.TransportSettings.ListenPort, typeIdList, maxTypeId, isInit); #endregion #region Set HashCollections Interlocked.Exchange(ref tagHashCollection, InitializeTagHashCollection(storageConfiguration)); Interlocked.Exchange(ref stringHashCollection, InitializeStringHashCollection(storageConfiguration)); #endregion #endregion }