コード例 #1
0
        public OutsideRuntimeClient(
            ILoggerFactory loggerFactory,
            IOptions <ClientMessagingOptions> clientMessagingOptions,
            IOptions <StatisticsOptions> statisticsOptions,
            ApplicationRequestsStatisticsGroup appRequestStatistics,
            StageAnalysisStatisticsGroup schedulerStageStatistics,
            ClientStatisticsManager clientStatisticsManager,
            MessagingTrace messagingTrace,
            IServiceProvider serviceProvider)
        {
            this.ServiceProvider          = serviceProvider;
            this.loggerFactory            = loggerFactory;
            this.statisticsOptions        = statisticsOptions;
            this.appRequestStatistics     = appRequestStatistics;
            this.schedulerStageStatistics = schedulerStageStatistics;
            this.ClientStatistics         = clientStatisticsManager;
            this.messagingTrace           = messagingTrace;
            this.logger   = loggerFactory.CreateLogger <OutsideRuntimeClient>();
            this.clientId = ClientGrainId.Create();
            callbacks     = new ConcurrentDictionary <CorrelationId, CallbackData>();
            this.clientMessagingOptions = clientMessagingOptions.Value;

            this.sharedCallbackData = new SharedCallbackData(
                msg => this.UnregisterCallback(msg.Id),
                this.loggerFactory.CreateLogger <CallbackData>(),
                this.clientMessagingOptions,
                this.appRequestStatistics,
                this.clientMessagingOptions.ResponseTimeout);
        }
コード例 #2
0
 public OutsideRuntimeClient(ILoggerFactory loggerFactory, IOptions <ClientMessagingOptions> clientMessagingOptions)
 {
     this.loggerFactory     = loggerFactory;
     this.logger            = loggerFactory.CreateLogger <OutsideRuntimeClient>();
     this.handshakeClientId = GrainId.NewClientId();
     tryResendMessage       = TryResendMessage;
     unregisterCallback     = msg => UnRegisterCallback(msg.Id);
     callbacks                   = new ConcurrentDictionary <CorrelationId, CallbackData>();
     localObjects                = new ConcurrentDictionary <GuidId, LocalObjectData>();
     this.callBackDataLogger     = loggerFactory.CreateLogger <CallbackData>();
     this.timerLogger            = loggerFactory.CreateLogger <SafeTimer>();
     this.clientMessagingOptions = clientMessagingOptions.Value;
 }
コード例 #3
0
 public OutsideRuntimeClient(
     ILoggerFactory loggerFactory,
     IOptions <ClientMessagingOptions> clientMessagingOptions,
     IOptions <TypeManagementOptions> typeManagementOptions,
     IOptions <StatisticsOptions> statisticsOptions,
     ApplicationRequestsStatisticsGroup appRequestStatistics,
     StageAnalysisStatisticsGroup schedulerStageStatistics,
     ClientStatisticsManager clientStatisticsManager)
 {
     this.loggerFactory            = loggerFactory;
     this.statisticsOptions        = statisticsOptions;
     this.appRequestStatistics     = appRequestStatistics;
     this.schedulerStageStatistics = schedulerStageStatistics;
     this.ClientStatistics         = clientStatisticsManager;
     this.logger            = loggerFactory.CreateLogger <OutsideRuntimeClient>();
     this.handshakeClientId = GrainId.NewClientId();
     callbacks = new ConcurrentDictionary <CorrelationId, CallbackData>();
     this.clientMessagingOptions = clientMessagingOptions.Value;
     this.typeMapRefreshInterval = typeManagementOptions.Value.TypeMapRefreshInterval;
 }
コード例 #4
0
 public OutsideRuntimeClient(
     ILoggerFactory loggerFactory,
     IOptions <ClientMessagingOptions> clientMessagingOptions,
     IOptions <TypeManagementOptions> typeManagementOptions,
     IOptions <StatisticsOptions> statisticsOptions)
 {
     this.loggerFactory     = loggerFactory;
     this.statisticsOptions = statisticsOptions;
     this.logger            = loggerFactory.CreateLogger <OutsideRuntimeClient>();
     this.handshakeClientId = GrainId.NewClientId();
     tryResendMessage       = TryResendMessage;
     unregisterCallback     = msg => UnRegisterCallback(msg.Id);
     callbacks                   = new ConcurrentDictionary <CorrelationId, CallbackData>();
     localObjects                = new ConcurrentDictionary <GuidId, LocalObjectData>();
     this.callBackDataLogger     = loggerFactory.CreateLogger <CallbackData>();
     this.timerLogger            = loggerFactory.CreateLogger <SafeTimer>();
     this.clientMessagingOptions = clientMessagingOptions.Value;
     this.typeMapRefreshInterval = typeManagementOptions.Value.TypeMapRefreshInterval;
     this.responseTimeout        = clientMessagingOptions.Value.ResponseTimeout;
 }
コード例 #5
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.config = this.ServiceProvider.GetRequiredService <ClientConfiguration>();

            var resolvedClientMessagingOptions = this.ServiceProvider.GetRequiredService <IOptions <ClientMessagingOptions> >();

            this.clientMessagingOptions = resolvedClientMessagingOptions.Value;

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

            this.ServiceProvider.GetService <TelemetryManager>()?.AddFromConfiguration(this.ServiceProvider, config.TelemetryConfiguration);

            var statisticsOptions = this.ServiceProvider.GetRequiredService <IOptions <StatisticsOptions> >();

            StatisticsCollector.Initialize(statisticsOptions.Value.CollectionLevel);

            BufferPool.InitGlobalBufferPool(resolvedClientMessagingOptions);

            try
            {
                AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;

                clientProviderRuntime     = this.ServiceProvider.GetRequiredService <ClientProviderRuntime>();
                statisticsProviderManager = this.ServiceProvider.GetRequiredService <StatisticsProviderManager>();
                var statsProviderName = statisticsProviderManager.LoadProvider(config.ProviderConfigurations)
                                        .WaitForResultWithThrow(initTimeout);
                if (statsProviderName != null)
                {
                    statisticsOptions.Value.ProviderName = statsProviderName;
                }

                responseTimeout   = Debugger.IsAttached ? Constants.DEFAULT_RESPONSE_TIMEOUT : config.ResponseTimeout;
                this.localAddress = ClusterConfiguration.GetLocalIPAddress(config.PreferredFamily, config.NetInterface);

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

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

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

                if (StatisticsCollector.CollectThreadTimeTrackingStats)
                {
                    incomingMessagesThreadTimeTracking = new ThreadTrackingStatistic("ClientReceiver", this.loggerFactory);
                }
            }
            catch (Exception exc)
            {
                if (logger != null)
                {
                    logger.Error(ErrorCode.Runtime_Error_100319, "OutsideRuntimeClient constructor failed.", exc);
                }
                ConstructorReset();
                throw;
            }
        }