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); }
internal void ConsumeServices(IServiceProvider services) { try { AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload; 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.messageFactory = this.ServiceProvider.GetService <MessageFactory>(); var serializationManager = this.ServiceProvider.GetRequiredService <SerializationManager>(); this.localObjects = new InvokableObjectManager( this, serializationManager, this.loggerFactory.CreateLogger <InvokableObjectManager>()); this.sharedCallbackData = new SharedCallbackData( this.TryResendMessage, msg => this.UnregisterCallback(msg.Id), this.loggerFactory.CreateLogger <CallbackData>(), this.clientMessagingOptions, serializationManager, this.appRequestStatistics); var timerLogger = this.loggerFactory.CreateLogger <SafeTimer>(); var minTicks = Math.Min(this.clientMessagingOptions.ResponseTimeout.Ticks, TimeSpan.FromSeconds(1).Ticks); var period = TimeSpan.FromTicks(minTicks); this.callbackTimer = new SafeTimer(timerLogger, this.OnCallbackExpiryTick, null, period, period); this.GrainReferenceRuntime = this.ServiceProvider.GetRequiredService <IGrainReferenceRuntime>(); BufferPool.InitGlobalBufferPool(this.clientMessagingOptions); this.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; } }