Exemplo n.º 1
0
        public OutsideRuntimeClient(
            ILoggerFactory loggerFactory,
            IOptions <ClientMessagingOptions> clientMessagingOptions,
            IOptions <TypeManagementOptions> typeManagementOptions,
            IOptions <StatisticsOptions> statisticsOptions,
            ApplicationRequestsStatisticsGroup appRequestStatistics,
            StageAnalysisStatisticsGroup schedulerStageStatistics,
            ClientStatisticsManager clientStatisticsManager,
            MessagingTrace messagingTrace)
        {
            this.loggerFactory            = loggerFactory;
            this.statisticsOptions        = statisticsOptions;
            this.appRequestStatistics     = appRequestStatistics;
            this.schedulerStageStatistics = schedulerStageStatistics;
            this.ClientStatistics         = clientStatisticsManager;
            this.messagingTrace           = messagingTrace;
            this.logger            = loggerFactory.CreateLogger <OutsideRuntimeClient>();
            this.handshakeClientId = GrainId.NewClientId();
            callbacks = new ConcurrentDictionary <CorrelationId, CallbackData>();
            this.clientMessagingOptions = clientMessagingOptions.Value;
            this.typeMapRefreshInterval = typeManagementOptions.Value.TypeMapRefreshInterval;

            this.sharedCallbackData = new SharedCallbackData(
                msg => this.UnregisterCallback(msg.Id),
                this.loggerFactory.CreateLogger <CallbackData>(),
                this.clientMessagingOptions,
                this.appRequestStatistics,
                this.clientMessagingOptions.ResponseTimeout);
        }
Exemplo n.º 2
0
        public ThreadPoolExecutor(
            ThreadPoolExecutorOptions options,
            SchedulerStatisticsGroup schedulerStatistics,
            StageAnalysisStatisticsGroup schedulerStageStatistics,
            IOptions <StatisticsOptions> statisticsOptions)
        {
            this.options                  = options ?? throw new ArgumentNullException(nameof(options));
            this.schedulerStatistics      = schedulerStatistics;
            this.schedulerStageStatistics = schedulerStageStatistics;
            this.statisticsOptions        = statisticsOptions;

            workQueue = new ThreadPoolWorkQueue();

            statistic = new ThreadPoolTrackingStatistic(options.Name, options.LoggerFactory, statisticsOptions, schedulerStageStatistics);

            executingWorkTracker = new ExecutingWorkItemsTracker(this);

            log = options.LoggerFactory.CreateLogger <ThreadPoolExecutor>();

            options.CancellationTokenSource.Token.Register(Complete);

            for (var threadIndex = 0; threadIndex < options.DegreeOfParallelism; threadIndex++)
            {
                RunWorker(threadIndex);
            }
        }
Exemplo n.º 3
0
        public ThreadPoolThread(
            string name,
            CancellationToken cancellationToken,
            ILoggerFactory loggerFactory,
            IOptions <StatisticsOptions> statisticsOptions,
            StageAnalysisStatisticsGroup schedulerStageStatistics)
        {
            this.Name = name;
            this.cancellationToken = cancellationToken;
            this.log = loggerFactory.CreateLogger <ThreadPoolThread>();

            this.statisticsLevel = statisticsOptions.Value.CollectionLevel;
            if (this.statisticsLevel.CollectDetailedThreadStatistics())
            {
                threadTracking = new ThreadTrackingStatistic(name, loggerFactory, statisticsOptions, schedulerStageStatistics);
            }
        }
Exemplo n.º 4
0
        internal void ConsumeServices(IServiceProvider services)
        {
            this.ServiceProvider = services;

            var connectionLostHandlers = this.ServiceProvider.GetServices <ConnectionToClusterLostHandler>();

            foreach (var handler in connectionLostHandlers)
            {
                this.ClusterConnectionLost += handler;
            }

            var clientInvokeCallbacks = this.ServiceProvider.GetServices <ClientInvokeCallback>();

            foreach (var handler in clientInvokeCallbacks)
            {
                this.ClientInvokeCallback += handler;
            }

            this.InternalGrainFactory = this.ServiceProvider.GetRequiredService <IInternalGrainFactory>();
            this.ClientStatistics     = this.ServiceProvider.GetRequiredService <ClientStatisticsManager>();
            this.serializationManager = this.ServiceProvider.GetRequiredService <SerializationManager>();
            this.messageFactory       = this.ServiceProvider.GetService <MessageFactory>();

            this.GrainReferenceRuntime = this.ServiceProvider.GetRequiredService <IGrainReferenceRuntime>();

            this.schedulerStageStatistics = this.ServiceProvider.GetRequiredService <StageAnalysisStatisticsGroup>();
            this.appRequestStatistics     = this.ServiceProvider.GetRequiredService <ApplicationRequestsStatisticsGroup>();

            BufferPool.InitGlobalBufferPool(this.clientMessagingOptions);

            try
            {
                AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;

                clientProviderRuntime = this.ServiceProvider.GetRequiredService <ClientProviderRuntime>();

                this.localAddress = ConfigUtilities.GetLocalIPAddress(this.clientMessagingOptions.PreferredFamily, this.clientMessagingOptions.NetworkInterfaceName);

                // Client init / sign-on message
                logger.Info(ErrorCode.ClientInitializing, string.Format(
                                "{0} Initializing OutsideRuntimeClient on {1} at {2} Client Id = {3} {0}",
                                BARS, Dns.GetHostName(), localAddress, handshakeClientId));
                string startMsg = string.Format("{0} Starting OutsideRuntimeClient with runtime Version='{1}' in AppDomain={2}",
                                                BARS, RuntimeVersion.Current, PrintAppDomainDetails());
                logger.Info(ErrorCode.ClientStarting, startMsg);

                if (TestOnlyThrowExceptionDuringInit)
                {
                    throw new InvalidOperationException("TestOnlyThrowExceptionDuringInit");
                }

                this.gatewayListProvider = this.ServiceProvider.GetRequiredService <IGatewayListProvider>();

                var statisticsLevel = statisticsOptions.Value.CollectionLevel;
                if (statisticsLevel.CollectThreadTimeTrackingStats())
                {
                    incomingMessagesThreadTimeTracking = new ThreadTrackingStatistic("ClientReceiver", this.loggerFactory, this.statisticsOptions, this.schedulerStageStatistics);
                }
            }
            catch (Exception exc)
            {
                if (logger != null)
                {
                    logger.Error(ErrorCode.Runtime_Error_100319, "OutsideRuntimeClient constructor failed.", exc);
                }
                ConstructorReset();
                throw;
            }
        }
Exemplo n.º 5
0
        public ThreadPoolTrackingStatistic(string name, ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions, StageAnalysisStatisticsGroup schedulerStageStatistics)
        {
            this.statisticsLevel = statisticsOptions.Value.CollectionLevel;
            if (statisticsLevel.CollectQueueStats())
            {
                queueTracking = new QueueTrackingStatistic(name, statisticsOptions);
            }

            if (this.statisticsLevel.CollectDetailedThreadStatistics())
            {
                threadTracking = new ThreadTrackingStatistic(name, loggerFactory, statisticsOptions, schedulerStageStatistics);
            }
        }