Ejemplo n.º 1
0
 /// <summary>
 /// Initialize the factory
 /// </summary>
 /// <param name="providerConfig"></param>
 /// <param name="providerName"></param>
 /// <param name="log"></param>
 /// <param name="svcProvider"></param>
 public void Init(IProviderConfiguration providerConfig, string providerName, Logger log, IServiceProvider svcProvider)
 {
     logger          = log;
     serviceProvider = svcProvider;
     receivers       = new ConcurrentDictionary <QueueId, Receiver>();
     adapterConfig   = new GeneratorAdapterConfig(providerName);
     adapterConfig.PopulateFromProviderConfig(providerConfig);
     this.serializationManager = svcProvider.GetRequiredService <SerializationManager>();
     if (CacheMonitorFactory == null)
     {
         this.CacheMonitorFactory = (dimensions, logger) => new DefaultCacheMonitor(dimensions, logger);
     }
     if (this.BlockPoolMonitorFactory == null)
     {
         this.BlockPoolMonitorFactory = (dimensions, logger) => new DefaultBlockPoolMonitor(dimensions, logger);
     }
     if (this.ReceiverMonitorFactory == null)
     {
         this.ReceiverMonitorFactory = (dimensions, logger) => new DefaultQueueAdapterReceiverMonitor(dimensions, logger);
     }
     if (adapterConfig.GeneratorConfigType != null)
     {
         generatorConfig = (IStreamGeneratorConfig)(serviceProvider?.GetService(adapterConfig.GeneratorConfigType) ?? Activator.CreateInstance(adapterConfig.GeneratorConfigType));
         if (generatorConfig == null)
         {
             throw new ArgumentOutOfRangeException(nameof(providerConfig), "GeneratorConfigType not valid.");
         }
         generatorConfig.PopulateFromProviderConfig(providerConfig);
     }
     this.sharedDimensions = new MonitorAggregationDimensions(serviceProvider.GetService <GlobalConfiguration>(), serviceProvider.GetService <NodeConfiguration>());
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initialize the factory
 /// </summary>
 /// <param name="providerConfig"></param>
 /// <param name="providerName"></param>
 /// <param name="log"></param>
 /// <param name="svcProvider"></param>
 public void Init(IProviderConfiguration providerConfig, string providerName, Logger log, IServiceProvider svcProvider)
 {
     logger          = log;
     serviceProvider = svcProvider;
     receivers       = new ConcurrentDictionary <QueueId, Receiver>();
     adapterConfig   = new GeneratorAdapterConfig(providerName);
     adapterConfig.PopulateFromProviderConfig(providerConfig);
     if (adapterConfig.GeneratorConfigType != null)
     {
         generatorConfig = (IStreamGeneratorConfig)(serviceProvider?.GetService(adapterConfig.GeneratorConfigType) ?? Activator.CreateInstance(adapterConfig.GeneratorConfigType));
         if (generatorConfig == null)
         {
             throw new ArgumentOutOfRangeException(nameof(providerConfig), "GeneratorConfigType not valid.");
         }
         generatorConfig.PopulateFromProviderConfig(providerConfig);
     }
     // 10 meg buffer pool.  10 1 meg blocks
     bufferPool = new FixedSizeObjectPool <FixedSizeBuffer>(10, () => new FixedSizeBuffer(1 << 20));
 }