internal PersistentStreamPullingManager( GrainId id, string strProviderName, IStreamProviderRuntime runtime, IStreamPubSub streamPubSub, IQueueAdapterFactory adapterFactory, IStreamQueueBalancer streamQueueBalancer, TimeSpan queueGetPeriod, TimeSpan initQueueTimeout, TimeSpan maxEvenDeliveryTime) : base(id, runtime.ExecutingSiloAddress) { if (string.IsNullOrWhiteSpace(strProviderName)) { throw new ArgumentNullException("strProviderName"); } if (runtime == null) { throw new ArgumentNullException("runtime", "IStreamProviderRuntime runtime reference should not be null"); } if (streamPubSub == null) { throw new ArgumentNullException("streamPubSub", "StreamPubSub reference should not be null"); } if (streamQueueBalancer == null) { throw new ArgumentNullException("streamQueueBalancer", "IStreamQueueBalancer streamQueueBalancer reference should not be null"); } queuesToAgentsMap = new Dictionary<QueueId, PersistentStreamPullingAgent>(); streamProviderName = strProviderName; providerRuntime = runtime; pubSub = streamPubSub; this.queueGetPeriod = queueGetPeriod; this.initQueueTimeout = initQueueTimeout; this.maxEvenDeliveryTime = maxEvenDeliveryTime; nonReentrancyGuarantor = new AsyncSerialExecutor(); latestRingNotificationSequenceNumber = 0; latestCommandNumber = 0; queueBalancer = streamQueueBalancer; this.adapterFactory = adapterFactory; queueAdapterCache = adapterFactory.GetQueueAdapterCache(); logger = providerRuntime.GetLogger(GetType().Name + "-" + streamProviderName); logger.Info((int)ErrorCode.PersistentStreamPullingManager_01, "Created {0} for Stream Provider {1}.", GetType().Name, streamProviderName); IntValueStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_PULLING_AGENTS, strProviderName), () => queuesToAgentsMap.Count); }
internal PersistentStreamPullingManager( GrainId id, string strProviderName, IStreamProviderRuntime runtime, IStreamPubSub streamPubSub, IQueueAdapterFactory adapterFactory, IStreamQueueBalancer streamQueueBalancer, PersistentStreamProviderConfig config) : base(id, runtime.ExecutingSiloAddress) { if (string.IsNullOrWhiteSpace(strProviderName)) { throw new ArgumentNullException("strProviderName"); } if (runtime == null) { throw new ArgumentNullException("runtime", "IStreamProviderRuntime runtime reference should not be null"); } if (streamPubSub == null) { throw new ArgumentNullException("streamPubSub", "StreamPubSub reference should not be null"); } if (streamQueueBalancer == null) { throw new ArgumentNullException("streamQueueBalancer", "IStreamQueueBalancer streamQueueBalancer reference should not be null"); } queuesToAgentsMap = new Dictionary<QueueId, PersistentStreamPullingAgent>(); streamProviderName = strProviderName; providerRuntime = runtime; pubSub = streamPubSub; this.config = config; nonReentrancyGuarantor = new AsyncSerialExecutor(); latestRingNotificationSequenceNumber = 0; latestCommandNumber = 0; queueBalancer = streamQueueBalancer; this.adapterFactory = adapterFactory; queueAdapterCache = adapterFactory.GetQueueAdapterCache(); logger = TraceLogger.GetLogger(GetType().Name + "-" + streamProviderName, TraceLogger.LoggerType.Provider); Log(ErrorCode.PersistentStreamPullingManager_01, "Created {0} for Stream Provider {1}.", GetType().Name, streamProviderName); IntValueStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_PULLING_AGENTS, strProviderName), () => queuesToAgentsMap.Count); queuePrintTimer = base.RegisterTimer(AsyncTimerCallback, null, QUEUES_PRINT_PERIOD, QUEUES_PRINT_PERIOD); }
public async Task StartPullingAgents( string streamProviderName, StreamQueueBalancerType balancerType, IQueueAdapterFactory adapterFactory, IQueueAdapter queueAdapter, TimeSpan getQueueMsgsTimerPeriod, TimeSpan initQueueTimeout) { IStreamQueueBalancer queueBalancer = StreamQueueBalancerFactory.Create( balancerType, streamProviderName, Silo.CurrentSilo.LocalSiloStatusOracle, Silo.CurrentSilo.OrleansConfig, this, adapterFactory.GetStreamQueueMapper()); var managerId = GrainId.NewSystemTargetGrainIdByTypeCode(Constants.PULLING_AGENTS_MANAGER_SYSTEM_TARGET_TYPE_CODE); var manager = new PersistentStreamPullingManager(managerId, streamProviderName, this, adapterFactory, queueBalancer, getQueueMsgsTimerPeriod, initQueueTimeout); this.RegisterSystemTarget(manager); // Init the manager only after it was registered locally. var managerGrainRef = manager.AsReference <IPersistentStreamPullingManager>(); // Need to call it as a grain reference though. await managerGrainRef.Initialize(queueAdapter.AsImmutable()); }
public async Task <IPersistentStreamPullingManager> InitializePullingAgents( string streamProviderName, IQueueAdapterFactory adapterFactory, IQueueAdapter queueAdapter, PersistentStreamProviderConfig config) { IStreamQueueBalancer queueBalancer = StreamQueueBalancerFactory.Create( config.BalancerType, streamProviderName, Silo.CurrentSilo.LocalSiloStatusOracle, Silo.CurrentSilo.OrleansConfig, this, adapterFactory.GetStreamQueueMapper()); var managerId = GrainId.NewSystemTargetGrainIdByTypeCode(Constants.PULLING_AGENTS_MANAGER_SYSTEM_TARGET_TYPE_CODE); var manager = new PersistentStreamPullingManager(managerId, streamProviderName, this, this.PubSub(config.PubSubType), adapterFactory, queueBalancer, config); this.RegisterSystemTarget(manager); // Init the manager only after it was registered locally. var pullingAgentManager = manager.AsReference <IPersistentStreamPullingManager>(); // Need to call it as a grain reference though. await pullingAgentManager.Initialize(queueAdapter.AsImmutable()); return(pullingAgentManager); }
public async Task <IPersistentStreamPullingManager> InitializePullingAgents( string streamProviderName, IQueueAdapterFactory adapterFactory, IQueueAdapter queueAdapter) { IStreamQueueBalancer queueBalancer = CreateQueueBalancer(streamProviderName); var managerId = GrainId.NewSystemTargetGrainIdByTypeCode(Constants.PULLING_AGENTS_MANAGER_SYSTEM_TARGET_TYPE_CODE); var pubsubOptions = this.ServiceProvider.GetOptionsByName <StreamPubSubOptions>(streamProviderName); var pullingAgentOptions = this.ServiceProvider.GetOptionsByName <StreamPullingAgentOptions>(streamProviderName); var manager = new PersistentStreamPullingManager(managerId, streamProviderName, this, this.PubSub(pubsubOptions.PubSubType), adapterFactory, queueBalancer, pullingAgentOptions, this.loggerFactory); this.RegisterSystemTarget(manager); // Init the manager only after it was registered locally. var pullingAgentManager = manager.AsReference <IPersistentStreamPullingManager>(); // Need to call it as a grain reference though. await pullingAgentManager.Initialize(queueAdapter.AsImmutable()); return(pullingAgentManager); }
internal PersistentStreamPullingManager( GrainId id, string strProviderName, IStreamProviderRuntime runtime, IQueueAdapterFactory adapterFactory, IStreamQueueBalancer streamQueueBalancer, TimeSpan queueGetPeriod, TimeSpan initQueueTimeout, TimeSpan maxEvenDeliveryTime) : base(id, runtime.ExecutingSiloAddress) { if (string.IsNullOrWhiteSpace(strProviderName)) { throw new ArgumentNullException("strProviderName"); } if (runtime == null) { throw new ArgumentNullException("runtime", "IStreamProviderRuntime runtime reference should not be null"); } if (streamQueueBalancer == null) { throw new ArgumentNullException("streamQueueBalancer", "IStreamQueueBalancer streamQueueBalancer reference should not be null"); } queuesToAgentsMap = new Dictionary <QueueId, PersistentStreamPullingAgent>(); streamProviderName = strProviderName; providerRuntime = runtime; this.queueGetPeriod = queueGetPeriod; this.initQueueTimeout = initQueueTimeout; this.maxEvenDeliveryTime = maxEvenDeliveryTime; nonReentrancyGuarantor = new AsyncSerialExecutor(); latestRingNotificationSequenceNumber = 0; queueBalancer = streamQueueBalancer; this.adapterFactory = adapterFactory; queueAdapterCache = adapterFactory.GetQueueAdapterCache(); logger = providerRuntime.GetLogger(GetType().Name + "-" + streamProviderName); logger.Info((int)ErrorCode.PersistentStreamPullingManager_01, "Created {0} for Stream Provider {1}.", GetType().Name, streamProviderName); IntValueStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_PULLING_AGENTS, strProviderName), () => queuesToAgentsMap.Count); }