/// <summary> /// Factory initialization. /// </summary> /// <param name="providerConfig"></param> /// <param name="name"></param> /// <param name="svcProvider"></param> public void Init(IProviderConfiguration providerConfig, string name, IServiceProvider svcProvider) { logger = svcProvider.GetService <ILogger <MemoryAdapterFactory <TSerializer> > >(); this.loggerFactory = svcProvider.GetRequiredService <ILoggerFactory>(); serviceProvider = svcProvider; providerName = name; queueGrains = new ConcurrentDictionary <QueueId, IMemoryStreamQueueGrain>(); adapterConfig = new MemoryAdapterConfig(providerName); this.telemetryProducer = svcProvider.GetService <ITelemetryProducer>(); if (CacheMonitorFactory == null) { this.CacheMonitorFactory = (dimensions, telemetryProducer) => new DefaultCacheMonitor(dimensions, telemetryProducer); } if (this.BlockPoolMonitorFactory == null) { this.BlockPoolMonitorFactory = (dimensions, telemetryProducer) => new DefaultBlockPoolMonitor(dimensions, telemetryProducer); } if (this.ReceiverMonitorFactory == null) { this.ReceiverMonitorFactory = (dimensions, telemetryProducer) => new DefaultQueueAdapterReceiverMonitor(dimensions, telemetryProducer); } purgePredicate = new TimePurgePredicate(adapterConfig.DataMinTimeInCache, adapterConfig.DataMaxAgeInCache); grainFactory = (IGrainFactory)serviceProvider.GetService(typeof(IGrainFactory)); adapterConfig.PopulateFromProviderConfig(providerConfig); streamQueueMapper = new HashRingBasedStreamQueueMapper(adapterConfig.TotalQueueCount, adapterConfig.StreamProviderName); this.sharedDimensions = new MonitorAggregationDimensions(serviceProvider.GetService <GlobalConfiguration>(), serviceProvider.GetService <NodeConfiguration>()); this.serializer = MemoryMessageBodySerializerFactory <TSerializer> .GetOrCreateSerializer(svcProvider); }
/// <summary> /// Factory initialization. /// </summary> /// <param name="providerConfig"></param> /// <param name="name"></param> /// <param name="log"></param> /// <param name="svcProvider"></param> public void Init(IProviderConfiguration providerConfig, string name, Logger log, IServiceProvider svcProvider) { logger = log; serviceProvider = svcProvider; providerName = name; queueGrains = new ConcurrentDictionary <QueueId, IMemoryStreamQueueGrain>(); adapterConfig = new MemoryAdapterConfig(providerName); grainFactory = (IGrainFactory)serviceProvider.GetService(typeof(IGrainFactory)); adapterConfig.PopulateFromProviderConfig(providerConfig); streamQueueMapper = new HashRingBasedStreamQueueMapper(adapterConfig.TotalQueueCount, adapterConfig.StreamProviderName); // 10 meg buffer pool. 10 1 meg blocks bufferPool = new FixedSizeObjectPool <FixedSizeBuffer>(adapterConfig.CacheSizeMb, () => new FixedSizeBuffer(1 << 20)); }