Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 public MemoryAdapterFactory(string providerName, MemoryStreamOptions options, IServiceProvider serviceProvider, IGrainFactory grainFactory, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory)
 {
     this.Name              = providerName;
     this.options           = options ?? throw new ArgumentNullException(nameof(options));
     this.grainFactory      = grainFactory ?? throw new ArgumentNullException(nameof(grainFactory));
     this.telemetryProducer = telemetryProducer ?? throw new ArgumentNullException(nameof(telemetryProducer));
     this.loggerFactory     = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
     this.logger            = loggerFactory.CreateLogger <ILogger <MemoryAdapterFactory <TSerializer> > >();
     this.serializer        = MemoryMessageBodySerializerFactory <TSerializer> .GetOrCreateSerializer(serviceProvider);
 }
Exemplo n.º 3
0
 public MemoryAdapterFactory(string providerName, StreamCacheEvictionOptions cacheOptions, StreamStatisticOptions statisticOptions, HashRingStreamQueueMapperOptions queueMapperOptions,
                             IServiceProvider serviceProvider, IGrainFactory grainFactory, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory)
 {
     this.Name = providerName;
     this.queueMapperOptions = queueMapperOptions ?? throw new ArgumentNullException(nameof(queueMapperOptions));
     this.cacheOptions       = cacheOptions ?? throw new ArgumentNullException(nameof(cacheOptions));
     this.statisticOptions   = statisticOptions ?? throw new ArgumentException(nameof(statisticOptions));
     this.grainFactory       = grainFactory ?? throw new ArgumentNullException(nameof(grainFactory));
     this.telemetryProducer  = telemetryProducer ?? throw new ArgumentNullException(nameof(telemetryProducer));
     this.loggerFactory      = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
     this.logger             = loggerFactory.CreateLogger <ILogger <MemoryAdapterFactory <TSerializer> > >();
     this.serializer         = MemoryMessageBodySerializerFactory <TSerializer> .GetOrCreateSerializer(serviceProvider);
 }
Exemplo n.º 4
0
        /// <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));

            this.serializer = MemoryMessageBodySerializerFactory <TSerializer> .GetOrCreateSerializer(svcProvider);
        }
Exemplo n.º 5
0
 void IOnDeserialized.OnDeserialized(ISerializerContext context)
 {
     this.serializer = MemoryMessageBodySerializerFactory <TSerializer> .GetOrCreateSerializer(context.ServiceProvider);
 }