Exemplo n.º 1
0
        public SiloProviderRuntime(
            SiloInitializationParameters siloDetails,
            GlobalConfiguration config,
            IGrainFactory grainFactory,
            IConsistentRingProvider consistentRingProvider,
            ISiloRuntimeClient runtimeClient,
            IServiceProvider serviceProvider,
            ImplicitStreamSubscriberTable implicitStreamSubscriberTable,
            ISiloStatusOracle siloStatusOracle,
            OrleansTaskScheduler scheduler,
            ActivationDirectory activationDirectory)
        {
            this.siloDetails            = siloDetails;
            this.siloStatusOracle       = siloStatusOracle;
            this.scheduler              = scheduler;
            this.activationDirectory    = activationDirectory;
            this.consistentRingProvider = consistentRingProvider;
            this.runtimeClient          = runtimeClient;
            this.ServiceId              = config.ServiceId;
            this.SiloIdentity           = siloDetails.SiloAddress.ToLongString();
            this.GrainFactory           = grainFactory;
            this.ServiceProvider        = serviceProvider;

            this.grainBasedPubSub = new GrainBasedPubSubRuntime(this.GrainFactory);
            var tmp = new ImplicitStreamPubSub(implicitStreamSubscriberTable);

            this.implictPubSub = tmp;
            this.combinedGrainBasedAndImplicitPubSub = new StreamPubSubImpl(this.grainBasedPubSub, tmp);
        }
 internal SimpleMessageStreamProducer(
     StreamImpl <T> stream,
     string streamProviderName,
     IStreamProviderRuntime providerUtilities,
     bool fireAndForgetDelivery,
     bool optimizeForImmutableData,
     IStreamPubSub pubSub,
     bool isRewindable,
     SerializationManager serializationManager,
     ILogger <SimpleMessageStreamProducer <T> > logger)
 {
     this.stream                   = stream;
     this.streamProviderName       = streamProviderName;
     providerRuntime               = providerUtilities;
     this.pubSub                   = pubSub;
     this.serializationManager     = serializationManager;
     connectedToRendezvous         = false;
     this.fireAndForgetDelivery    = fireAndForgetDelivery;
     this.optimizeForImmutableData = optimizeForImmutableData;
     IsRewindable                  = isRewindable;
     isDisposed  = false;
     initLock    = new AsyncLock();
     this.logger = logger;
     ConnectToRendezvous().Ignore();
 }
        internal PersistentStreamPullingAgent(
            SystemTargetGrainId id,
            string strProviderName,
            ILoggerFactory loggerFactory,
            IStreamPubSub streamPubSub,
            IStreamFilter streamFilter,
            QueueId queueId,
            StreamPullingAgentOptions options,
            SiloAddress siloAddress)
            : base(id, siloAddress, true, loggerFactory)
        {
            if (strProviderName == null)
            {
                throw new ArgumentNullException("runtime", "PersistentStreamPullingAgent: strProviderName should not be null");
            }

            QueueId            = queueId;
            streamProviderName = strProviderName;
            pubSub             = streamPubSub;
            this.streamFilter  = streamFilter;
            pubSubCache        = new Dictionary <InternalStreamId, StreamConsumerCollection>();
            this.options       = options;
            numMessages        = 0;

            logger = loggerFactory.CreateLogger($"{this.GetType().Namespace}.{streamProviderName}");
            logger.Info(ErrorCode.PersistentStreamPullingAgent_01,
                        "Created {0} {1} for Stream Provider {2} on silo {3} for Queue {4}.",
                        GetType().Name, ((ISystemTargetBase)this).GrainId.ToString(), streamProviderName, Silo, QueueId.ToStringWithHashCode());
            numReadMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_READ_MESSAGES, StatisticUniquePostfix));
            numSentMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_SENT_MESSAGES, StatisticUniquePostfix));
            // TODO: move queue cache size statistics tracking into queue cache implementation once Telemetry APIs and LogStatistics have been reconciled.
            //IntValueStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_QUEUE_CACHE_SIZE, statUniquePostfix), () => queueCache != null ? queueCache.Size : 0);
        }
        internal PersistentStreamPullingAgent(
            GrainId id, 
            string strProviderName,
            IStreamProviderRuntime runtime,
            IStreamPubSub streamPubSub,
            QueueId queueId,
            PersistentStreamProviderConfig config)
            : base(id, runtime.ExecutingSiloAddress, true)
        {
            if (runtime == null) throw new ArgumentNullException("runtime", "PersistentStreamPullingAgent: runtime reference should not be null");
            if (strProviderName == null) throw new ArgumentNullException("runtime", "PersistentStreamPullingAgent: strProviderName should not be null");

            QueueId = queueId;
            streamProviderName = strProviderName;
            providerRuntime = runtime;
            pubSub = streamPubSub;
            pubSubCache = new Dictionary<StreamId, StreamConsumerCollection>();
            safeRandom = new SafeRandom();
            this.config = config;
            numMessages = 0;

            logger = providerRuntime.GetLogger(GrainId + "-" + streamProviderName);
            logger.Info((int)ErrorCode.PersistentStreamPullingAgent_01, 
                "Created {0} {1} for Stream Provider {2} on silo {3} for Queue {4}.",
                GetType().Name, GrainId.ToDetailedString(), streamProviderName, Silo, QueueId.ToStringWithHashCode());

            string statUniquePostfix = strProviderName + "." + QueueId;
            numReadMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_READ_MESSAGES, statUniquePostfix));
            numSentMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_SENT_MESSAGES, statUniquePostfix));
            IntValueStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_PUBSUB_CACHE_SIZE, statUniquePostfix), () => pubSubCache.Count);
            // TODO: move queue cache size statistics tracking into queue cache implementation once Telemetry APIs and LogStatistics have been reconciled.
            //IntValueStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_QUEUE_CACHE_SIZE, statUniquePostfix), () => queueCache != null ? queueCache.Size : 0);
        }
Exemplo n.º 5
0
        public StreamConsumer(StreamImpl <T> stream, string streamProviderName, IStreamProviderRuntime providerUtilities, IStreamPubSub pubSub, bool isRewindable)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (providerUtilities == null)
            {
                throw new ArgumentNullException("providerUtilities");
            }
            if (pubSub == null)
            {
                throw new ArgumentNullException("pubSub");
            }

            logger                  = TraceLogger.GetLogger(string.Format("StreamConsumer<{0}>-{1}", typeof(T).Name, stream), TraceLogger.LoggerType.Runtime);
            this.stream             = stream;
            this.streamProviderName = streamProviderName;
            providerRuntime         = providerUtilities;
            this.pubSub             = pubSub;
            IsRewindable            = isRewindable;
            myExtension             = null;
            myGrainReference        = null;
            bindExtLock             = new AsyncLock();
        }
Exemplo n.º 6
0
        internal PersistentStreamPullingAgent(
            GrainId id, 
            string strProviderName,
            IStreamProviderRuntime runtime,
            IStreamPubSub streamPubSub,
            QueueId queueId,
            PersistentStreamProviderConfig config)
            : base(id, runtime.ExecutingSiloAddress, true)
        {
            if (runtime == null) throw new ArgumentNullException("runtime", "PersistentStreamPullingAgent: runtime reference should not be null");
            if (strProviderName == null) throw new ArgumentNullException("runtime", "PersistentStreamPullingAgent: strProviderName should not be null");

            QueueId = queueId;
            streamProviderName = strProviderName;
            providerRuntime = runtime;
            pubSub = streamPubSub;
            pubSubCache = new Dictionary<StreamId, StreamConsumerCollection>();
            safeRandom = new SafeRandom();
            this.config = config;
            numMessages = 0;

            logger = providerRuntime.GetLogger(GrainId + "-" + streamProviderName);
            logger.Info((int)ErrorCode.PersistentStreamPullingAgent_01, 
                "Created {0} {1} for Stream Provider {2} on silo {3} for Queue {4}.",
                GetType().Name, GrainId.ToDetailedString(), streamProviderName, Silo, QueueId.ToStringWithHashCode());

            string statUniquePostfix = strProviderName + "." + QueueId;
            numReadMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_READ_MESSAGES, statUniquePostfix));
            numSentMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_SENT_MESSAGES, statUniquePostfix));
            IntValueStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_PUBSUB_CACHE_SIZE, statUniquePostfix), () => pubSubCache.Count);
            IntValueStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_QUEUE_CACHE_SIZE, statUniquePostfix), () => queueCache !=null ? queueCache.Size : 0);
        }
        internal PersistentStreamPullingAgent(
            GrainId id,
            string strProviderName,
            IStreamProviderRuntime runtime,
            QueueId queueId,
            TimeSpan queueGetPeriod,
            TimeSpan initQueueTimeout)
            : base(id, runtime.ExecutingSiloAddress, true)
        {
            if (runtime == null)
            {
                throw new ArgumentNullException("runtime", "PersistentStreamPullingAgent: runtime reference should not be null");
            }

            QueueId               = queueId;
            streamProviderName    = strProviderName;
            providerRuntime       = runtime;
            pubSub                = runtime.PubSub(StreamPubSubType.GrainBased);
            pubSubCache           = new Dictionary <StreamId, StreamConsumerCollection>();
            safeRandom            = new SafeRandom();
            this.queueGetPeriod   = queueGetPeriod;
            this.initQueueTimeout = initQueueTimeout;
            numMessages           = 0;

            logger = providerRuntime.GetLogger(this.GrainId.ToString() + "-" + streamProviderName);
            logger.Info((int)ErrorCode.PersistentStreamPullingAgent_01,
                        "Created {0} {1} for Stream Provider {2} on silo {3} for Queue {4}.",
                        this.GetType().Name, this.GrainId.ToDetailedString(), streamProviderName, base.Silo, QueueId.ToStringWithHashCode());

            numReadMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_READ_MESSAGES, strProviderName));
            numSentMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_SENT_MESSAGES, strProviderName));
        }
Exemplo n.º 8
0
 StreamPubSubWrapper(IRuntimeClient client, string[] providers, IStreamPubSub registry, Func <StreamIdentity, StreamPubSubMatch[]> matcher)
 {
     this.client    = client;
     this.providers = providers;
     this.registry  = registry;
     this.matcher   = matcher;
 }
        internal PersistentStreamPullingAgent(
            GrainId id, 
            string strProviderName,
            IStreamProviderRuntime runtime,
            QueueId queueId, 
            TimeSpan queueGetPeriod,
            TimeSpan initQueueTimeout,
            TimeSpan maxDeliveryTime)
            : base(id, runtime.ExecutingSiloAddress, true)
        {
            if (runtime == null) throw new ArgumentNullException("runtime", "PersistentStreamPullingAgent: runtime reference should not be null");
            if (strProviderName == null) throw new ArgumentNullException("runtime", "PersistentStreamPullingAgent: strProviderName should not be null");

            QueueId = queueId;
            streamProviderName = strProviderName;
            providerRuntime = runtime;
            pubSub = runtime.PubSub(StreamPubSubType.GrainBased);
            pubSubCache = new Dictionary<StreamId, StreamConsumerCollection>();
            safeRandom = new SafeRandom();
            this.queueGetPeriod = queueGetPeriod;
            this.initQueueTimeout = initQueueTimeout;
            this.maxDeliveryTime = maxDeliveryTime;
            numMessages = 0;

            logger = providerRuntime.GetLogger(GrainId + "-" + streamProviderName);
            logger.Info((int)ErrorCode.PersistentStreamPullingAgent_01, 
                "Created {0} {1} for Stream Provider {2} on silo {3} for Queue {4}.",
                GetType().Name, GrainId.ToDetailedString(), streamProviderName, Silo, QueueId.ToStringWithHashCode());

            numReadMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_READ_MESSAGES, strProviderName));
            numSentMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_SENT_MESSAGES, strProviderName));
        }
Exemplo n.º 10
0
        public SiloProviderRuntime(
            ILocalSiloDetails siloDetails,
            IOptions <ClusterOptions> clusterOptions,
            IConsistentRingProvider consistentRingProvider,
            ISiloRuntimeClient runtimeClient,
            ImplicitStreamSubscriberTable implicitStreamSubscriberTable,
            ISiloStatusOracle siloStatusOracle,
            OrleansTaskScheduler scheduler,
            ActivationDirectory activationDirectory,
            ILoggerFactory loggerFactory)
        {
            this.loggerFactory          = loggerFactory;
            this.siloStatusOracle       = siloStatusOracle;
            this.scheduler              = scheduler;
            this.activationDirectory    = activationDirectory;
            this.consistentRingProvider = consistentRingProvider;
            this.runtimeClient          = runtimeClient;
            this.ServiceId              = clusterOptions.Value.ServiceId;
            this.SiloIdentity           = siloDetails.SiloAddress.ToLongString();

            this.grainBasedPubSub = new GrainBasedPubSubRuntime(this.GrainFactory);
            var tmp = new ImplicitStreamPubSub(this.runtimeClient.InternalGrainFactory, implicitStreamSubscriberTable);

            this.implictPubSub = tmp;
            this.combinedGrainBasedAndImplicitPubSub = new StreamPubSubImpl(this.grainBasedPubSub, tmp);
        }
Exemplo n.º 11
0
        public StreamConsumer(StreamImpl <T> stream, string streamProviderName, IStreamProviderRuntime runtime, IStreamPubSub pubSub, ILogger logger, bool isRewindable)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (runtime == null)
            {
                throw new ArgumentNullException(nameof(runtime));
            }
            if (pubSub == null)
            {
                throw new ArgumentNullException(nameof(pubSub));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            this.logger             = logger;
            this.stream             = stream;
            this.streamProviderName = streamProviderName;
            this.providerRuntime    = runtime;
            this.pubSub             = pubSub;
            this.IsRewindable       = isRewindable;
            this.myExtension        = null;
            this.myGrainReference   = null;
            this.bindExtLock        = new AsyncLock();
        }
Exemplo n.º 12
0
        internal PersistentStreamPullingAgent(
            GrainId id,
            string strProviderName,
            IStreamProviderRuntime runtime,
            IStreamPubSub streamPubSub,
            QueueId queueId,
            PersistentStreamProviderConfig config)
            : base(id, runtime.ExecutingSiloAddress, true)
        {
            if (runtime == null)
            {
                throw new ArgumentNullException("runtime", "PersistentStreamPullingAgent: runtime reference should not be null");
            }
            if (strProviderName == null)
            {
                throw new ArgumentNullException("runtime", "PersistentStreamPullingAgent: strProviderName should not be null");
            }

            QueueId            = queueId;
            streamProviderName = strProviderName;
            pubSub             = streamPubSub;
            pubSubCache        = new Dictionary <StreamId, StreamConsumerCollection>();
            safeRandom         = new SafeRandom();
            this.config        = config;
            numMessages        = 0;

            logger = runtime.GetLogger(((ISystemTargetBase)this).GrainId + "-" + streamProviderName);
            logger.Info(ErrorCode.PersistentStreamPullingAgent_01,
                        "Created {0} {1} for Stream Provider {2} on silo {3} for Queue {4}.",
                        GetType().Name, ((ISystemTargetBase)this).GrainId.ToDetailedString(), streamProviderName, Silo, QueueId.ToStringWithHashCode());
            numReadMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_READ_MESSAGES, StatisticUniquePostfix));
            numSentMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_SENT_MESSAGES, StatisticUniquePostfix));
            // TODO: move queue cache size statistics tracking into queue cache implementation once Telemetry APIs and LogStatistics have been reconciled.
            //IntValueStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_QUEUE_CACHE_SIZE, statUniquePostfix), () => queueCache != null ? queueCache.Size : 0);
        }
Exemplo n.º 13
0
        public void StreamingInitialize()
        {
            grainBasedPubSub = new GrainBasedPubSubRuntime(GrainFactory);
            var tmp = new ImplicitStreamPubSub(this.grainFactory, this.implicitSubscriberTable);

            implicitPubSub = tmp;
            combinedGrainBasedAndImplicitPubSub = new StreamPubSubImpl(grainBasedPubSub, tmp);
            streamDirectory = new StreamDirectory();
        }
 internal SimpleMessageStreamProducerExtension(IStreamProviderRuntime providerRt, IStreamPubSub pubsub, bool fireAndForget, bool optimizeForImmutable)
 {
     providerRuntime = providerRt;
     streamPubSub = pubsub;
     fireAndForgetDelivery = fireAndForget;
     optimizeForImmutableData = optimizeForImmutable;
     remoteConsumers = new Dictionary<StreamId, StreamConsumerExtensionCollection>();
     logger = providerRuntime.GetLogger(GetType().Name);
 }
 internal SimpleMessageStreamProducerExtension(IStreamProviderRuntime providerRt, IStreamPubSub pubsub, bool fireAndForget, bool optimizeForImmutable)
 {
     providerRuntime          = providerRt;
     streamPubSub             = pubsub;
     fireAndForgetDelivery    = fireAndForget;
     optimizeForImmutableData = optimizeForImmutable;
     remoteConsumers          = new Dictionary <StreamId, StreamConsumerExtensionCollection>();
     logger = providerRuntime.GetLogger(GetType().Name);
 }
 internal SimpleMessageStreamProducerExtension(IStreamProviderRuntime providerRt, IStreamPubSub pubsub, ILoggerFactory loggerFactory, bool fireAndForget, bool optimizeForImmutable)
 {
     providerRuntime          = providerRt;
     streamPubSub             = pubsub;
     fireAndForgetDelivery    = fireAndForget;
     optimizeForImmutableData = optimizeForImmutable;
     remoteConsumers          = new Dictionary <StreamId, StreamConsumerExtensionCollection>();
     logger             = loggerFactory.CreateLogger <SimpleMessageStreamProducerExtension>();
     this.loggerFactory = loggerFactory;
 }
Exemplo n.º 17
0
        public void StreamingInitialize(ImplicitStreamSubscriberTable implicitStreamSubscriberTable)
        {
            if (null == implicitStreamSubscriberTable)
            {
                throw new ArgumentNullException("implicitStreamSubscriberTable");
            }
            grainBasedPubSub = new GrainBasedPubSubRuntime(GrainFactory);
            var tmp = new ImplicitStreamPubSub(implicitStreamSubscriberTable);

            implictPubSub = tmp;
            combinedGrainBasedAndImplicitPubSub = new StreamPubSubImpl(grainBasedPubSub, tmp);
            streamDirectory = new StreamDirectory();
        }
Exemplo n.º 18
0
        public void StreamingInitialize()
        {
            this.implicitStreamSubscriberTable = new ImplicitStreamSubscriberTable();
            this.grainBasedPubSub = new GrainBasedPubSubRuntime(this.GrainFactory);
            var tmp = new ImplicitStreamPubSub(this.implicitStreamSubscriberTable);

            this.implictPubSub = tmp;
            this.combinedGrainBasedAndImplicitPubSub = new StreamPubSubImpl(this.grainBasedPubSub, tmp);

            var typeManager = this.ServiceProvider.GetRequiredService <GrainTypeManager>();

            Type[] types = typeManager.GrainClassTypeData.Select(t => t.Value.Type).ToArray();
            this.ImplicitStreamSubscriberTable.InitImplicitStreamSubscribers(types);
        }
Exemplo n.º 19
0
        public StreamPubSubImpl(IStreamPubSub explicitPubSub, ImplicitStreamPubSub implicitPubSub)
        {
            if (explicitPubSub == null)
            {
                throw new ArgumentNullException("explicitPubSub");
            }

            if (implicitPubSub == null)
            {
                throw new ArgumentNullException("implicitPubSub");
            }

            this.explicitPubSub = explicitPubSub;
            this.implicitPubSub = implicitPubSub;
        }
Exemplo n.º 20
0
        internal SimpleMessageStreamProducer(StreamImpl <T> stream, string streamProviderName, IStreamProviderRuntime providerUtilities, bool fireAndForgetDelivery, bool isRewindable)
        {
            this.stream             = stream;
            this.streamProviderName = streamProviderName;
            providerRuntime         = providerUtilities;
            pubSub = providerRuntime.PubSub(StreamPubSubType.GrainBased);
            connectedToRendezvous      = false;
            this.fireAndForgetDelivery = fireAndForgetDelivery;
            IsRewindable = isRewindable;
            isDisposed   = false;
            logger       = providerRuntime.GetLogger(GetType().Name);
            initLock     = new AsyncLock();

            ConnectToRendezvous().Ignore();
        }
Exemplo n.º 21
0
        public StreamPubSubImpl(IStreamPubSub explicitPubSub, ImplicitStreamPubSub implicitPubSub)
        {
            if (explicitPubSub == null)
            {
                throw new ArgumentNullException("explicitPubSub");
            }

            if (implicitPubSub == null)
            {
                throw new ArgumentNullException("implicitPubSub");
            }

            this.explicitPubSub = explicitPubSub;
            this.implicitPubSub = implicitPubSub;
        }
        internal PersistentStreamPullingManager(
            SystemTargetGrainId managerId,
            string strProviderName,
            IStreamProviderRuntime runtime,
            IStreamPubSub streamPubSub,
            IQueueAdapterFactory adapterFactory,
            IStreamQueueBalancer streamQueueBalancer,
            IStreamFilter streamFilter,
            StreamPullingAgentOptions options,
            ILoggerFactory loggerFactory,
            SiloAddress siloAddress)
            : base(managerId, siloAddress, lowPriority: false, loggerFactory)
        {
            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.options           = options;
            nonReentrancyGuarantor = new AsyncSerialExecutor();
            latestRingNotificationSequenceNumber = 0;
            latestCommandNumber = 0;
            queueBalancer       = streamQueueBalancer;
            this.streamFilter   = streamFilter;
            this.adapterFactory = adapterFactory;

            queueAdapterCache = adapterFactory.GetQueueAdapterCache();
            logger            = loggerFactory.CreateLogger($"{GetType().FullName}.{streamProviderName}");
            Log(ErrorCode.PersistentStreamPullingManager_01, "Created {0} for Stream Provider {1}.", GetType().Name, streamProviderName);
            this.loggerFactory = loggerFactory;
            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,
            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,
            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);
        }
Exemplo n.º 26
0
        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            = LogManager.GetLogger(GetType().Name + "-" + streamProviderName, 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);
        }
Exemplo n.º 27
0
        internal PersistentStreamPullingAgent(
            SystemTargetGrainId id,
            string strProviderName,
            ILoggerFactory loggerFactory,
            IStreamPubSub streamPubSub,
            IStreamFilter streamFilter,
            QueueId queueId,
            StreamPullingAgentOptions options,
            SiloAddress siloAddress,
            IQueueAdapter queueAdapter,
            IQueueAdapterCache queueAdapterCache,
            IStreamFailureHandler streamFailureHandler)
            : base(id, siloAddress, true, loggerFactory)
        {
            if (strProviderName == null)
            {
                throw new ArgumentNullException("runtime", "PersistentStreamPullingAgent: strProviderName should not be null");
            }

            QueueId                   = queueId;
            streamProviderName        = strProviderName;
            pubSub                    = streamPubSub;
            this.streamFilter         = streamFilter;
            pubSubCache               = new Dictionary <InternalStreamId, StreamConsumerCollection>();
            this.options              = options;
            this.queueAdapter         = queueAdapter ?? throw new ArgumentNullException(nameof(queueAdapter));
            this.streamFailureHandler = streamFailureHandler ?? throw new ArgumentNullException(nameof(streamFailureHandler));;
            this.queueAdapterCache    = queueAdapterCache;
            numMessages               = 0;

            logger = loggerFactory.CreateLogger($"{this.GetType().Namespace}.{streamProviderName}");
            logger.LogInformation(
                (int)ErrorCode.PersistentStreamPullingAgent_01,
                "Created {Name} {Id} for Stream Provider {StreamProvider} on silo {Silo} for Queue {Queue}.",
                GetType().Name,
                ((ISystemTargetBase)this).GrainId.ToString(),
                streamProviderName,
                Silo,
                QueueId.ToStringWithHashCode());
            numReadMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_READ_MESSAGES, StatisticUniquePostfix));
            numSentMessagesCounter = CounterStatistic.FindOrCreate(new StatisticName(StatisticNames.STREAMS_PERSISTENT_STREAM_NUM_SENT_MESSAGES, StatisticUniquePostfix));
        }
Exemplo n.º 28
0
        public SiloStreamProviderRuntime(
            IConsistentRingProvider consistentRingProvider,
            InsideRuntimeClient runtimeClient,
            ImplicitStreamSubscriberTable implicitStreamSubscriberTable,
            ILoggerFactory loggerFactory,
            ILocalSiloDetails siloDetails,
            IGrainContextAccessor grainContextAccessor)
        {
            this.loggerFactory          = loggerFactory;
            this.siloDetails            = siloDetails;
            this.grainContextAccessor   = grainContextAccessor;
            this.consistentRingProvider = consistentRingProvider;
            this.runtimeClient          = runtimeClient;
            this.logger           = this.loggerFactory.CreateLogger <SiloProviderRuntime>();
            this.grainBasedPubSub = new GrainBasedPubSubRuntime(this.GrainFactory);
            var tmp = new ImplicitStreamPubSub(this.runtimeClient.InternalGrainFactory, implicitStreamSubscriberTable);

            this.implictPubSub = tmp;
            this.combinedGrainBasedAndImplicitPubSub = new StreamPubSubImpl(this.grainBasedPubSub, tmp);
        }
        public ClientStreamingProviderRuntime(
            IInternalGrainFactory grainFactory,
            IServiceProvider serviceProvider,
            ILoggerFactory loggerFactory,
            ImplicitStreamSubscriberTable implicitSubscriberTable,
            ClientGrainContext clientContext)
        {
            this.grainFactory            = grainFactory;
            this.ServiceProvider         = serviceProvider;
            this.implicitSubscriberTable = implicitSubscriberTable;
            this.clientContext           = clientContext;
            this.runtimeClient           = serviceProvider.GetService <IRuntimeClient>();
            //all async timer created through current class all share this logger for perf reasons
            this.timerLogger = loggerFactory.CreateLogger <AsyncTaskSafeTimer>();
            grainBasedPubSub = new GrainBasedPubSubRuntime(GrainFactory);
            var tmp = new ImplicitStreamPubSub(this.grainFactory, this.implicitSubscriberTable);

            implicitPubSub = tmp;
            combinedGrainBasedAndImplicitPubSub = new StreamPubSubImpl(grainBasedPubSub, tmp);
            streamDirectory = new StreamDirectory();
        }
Exemplo n.º 30
0
        public SiloProviderRuntime(
            IConsistentRingProvider consistentRingProvider,
            ISiloRuntimeClient runtimeClient,
            ImplicitStreamSubscriberTable implicitStreamSubscriberTable,
            OrleansTaskScheduler scheduler,
            ActivationDirectory activationDirectory,
            ILoggerFactory loggerFactory,
            ILocalSiloDetails siloDetails)
        {
            this.loggerFactory          = loggerFactory;
            this.siloDetails            = siloDetails;
            this.scheduler              = scheduler;
            this.activationDirectory    = activationDirectory;
            this.consistentRingProvider = consistentRingProvider;
            this.runtimeClient          = runtimeClient;
            this.logger           = this.loggerFactory.CreateLogger <SiloProviderRuntime>();
            this.grainBasedPubSub = new GrainBasedPubSubRuntime(this.GrainFactory);
            var tmp = new ImplicitStreamPubSub(this.runtimeClient.InternalGrainFactory, implicitStreamSubscriberTable);

            this.implictPubSub = tmp;
            this.combinedGrainBasedAndImplicitPubSub = new StreamPubSubImpl(this.grainBasedPubSub, tmp);
        }
Exemplo n.º 31
0
        public SiloProviderRuntime(
            Silo silo,
            GlobalConfiguration config,
            IGrainFactory grainFactory,
            IConsistentRingProvider consistentRingProvider,
            ISiloRuntimeClient runtimeClient,
            IServiceProvider serviceProvider,
            ImplicitStreamSubscriberTable implicitStreamSubscriberTable)
        {
            this.silo = silo;
            this.consistentRingProvider = consistentRingProvider;
            this.runtimeClient          = runtimeClient;
            this.ServiceId       = config.ServiceId;
            this.SiloIdentity    = silo.SiloAddress.ToLongString();
            this.GrainFactory    = grainFactory;
            this.ServiceProvider = serviceProvider;

            this.grainBasedPubSub = new GrainBasedPubSubRuntime(this.GrainFactory);
            var tmp = new ImplicitStreamPubSub(implicitStreamSubscriberTable);

            this.implictPubSub = tmp;
            this.combinedGrainBasedAndImplicitPubSub = new StreamPubSubImpl(this.grainBasedPubSub, tmp);
        }
Exemplo n.º 32
0
 public StreamSubscriptionManager(IStreamPubSub streamPubSub, string managerType)
 {
     this.streamPubSub = streamPubSub;
     this.type         = managerType;
 }
Exemplo n.º 33
0
 StreamPubSubWrapper(string[] providers, IStreamPubSub registry, Func <StreamIdentity, StreamPubSubMatch[]> matcher)
 {
     this.providers = providers;
     this.registry  = registry;
     this.matcher   = matcher;
 }
        private static async Task <ISet <PubSubSubscriptionState> > PubsubRegisterProducer(IStreamPubSub pubSub, InternalStreamId streamId,
                                                                                           IStreamProducerExtension meAsStreamProducer, ILogger logger)
        {
            try
            {
                var streamData = await pubSub.RegisterProducer(streamId, meAsStreamProducer);

                return(streamData);
            }
            catch (Exception e)
            {
                logger.Error(ErrorCode.PersistentStreamPullingAgent_17, $"RegisterAsStreamProducer failed due to {e}", e);
                throw;
            }
        }
 internal StreamConsumerExtensionCollection(IStreamPubSub pubSub, Logger logger)
 {
     streamPubSub = pubSub;
     this.logger = logger;
     consumers = new ConcurrentDictionary<GuidId, Tuple<IStreamConsumerExtension, IStreamFilterPredicateWrapper>>();
 }
 internal StreamConsumerExtensionCollection(IStreamPubSub pubSub, Logger logger)
 {
     streamPubSub = pubSub;
     this.logger  = logger;
     consumers    = new ConcurrentDictionary <GuidId, Tuple <IStreamConsumerExtension, IStreamFilterPredicateWrapper> >();
 }
Exemplo n.º 37
0
 internal StreamConsumerExtensionCollection(IStreamPubSub pubSub, ILogger logger)
 {
     this.streamPubSub = pubSub;
     this.logger       = logger;
 }
Exemplo n.º 38
0
 StreamPubSubWrapper(string[] providers, IStreamPubSub registry, Func<StreamIdentity, StreamPubSubMatch[]> matcher)
 {
     this.providers = providers;
     this.registry = registry;
     this.matcher = matcher;
 }