public InsideRuntimeClient( ILocalSiloDetails siloDetails, ClusterConfiguration config, GrainTypeManager typeManager, TypeMetadataCache typeMetadataCache, OrleansTaskScheduler scheduler, IServiceProvider serviceProvider, SerializationManager serializationManager, MessageFactory messageFactory, IEnumerable <IGrainCallFilter> registeredInterceptors, Factory <ITransactionAgent> transactionAgent, ILoggerFactory loggerFactory) { this.ServiceProvider = serviceProvider; this.SerializationManager = serializationManager; MySilo = siloDetails.SiloAddress; disposables = new List <IDisposable>(); callbacks = new ConcurrentDictionary <CorrelationId, CallbackData>(); Config = config; config.OnConfigChange("Globals/Message", () => ResponseTimeout = Config.Globals.ResponseTimeout); this.typeManager = typeManager; this.messageFactory = messageFactory; this.transactionAgent = new Lazy <ITransactionAgent>(() => transactionAgent()); this.Scheduler = scheduler; this.ConcreteGrainFactory = new GrainFactory(this, typeMetadataCache); tryResendMessage = msg => this.Dispatcher.TryResendMessage(msg); unregisterCallback = msg => UnRegisterCallback(msg.Id); this.siloInterceptors = new List <IGrainCallFilter>(registeredInterceptors); this.logger = loggerFactory.CreateLogger <InsideRuntimeClient>(); this.invokeExceptionLogger = loggerFactory.CreateLogger($"{typeof(Grain).FullName}.InvokeException"); this.loggerFactory = loggerFactory; this.callbackDataLogger = new LoggerWrapper <CallbackData>(loggerFactory); this.timerLogger = loggerFactory.CreateLogger <SafeTimer>(); }
public InsideRuntimeClient( ILocalSiloDetails siloDetails, ClusterConfiguration config, GrainTypeManager typeManager, TypeMetadataCache typeMetadataCache, OrleansTaskScheduler scheduler, IServiceProvider serviceProvider, SerializationManager serializationManager, MessageFactory messageFactory, IEnumerable <IGrainCallFilter> registeredInterceptors) { this.ServiceProvider = serviceProvider; this.SerializationManager = serializationManager; MySilo = siloDetails.SiloAddress; disposables = new List <IDisposable>(); callbacks = new ConcurrentDictionary <CorrelationId, CallbackData>(); Config = config; config.OnConfigChange("Globals/Message", () => ResponseTimeout = Config.Globals.ResponseTimeout); this.typeManager = typeManager; this.messageFactory = messageFactory; this.Scheduler = scheduler; this.ConcreteGrainFactory = new GrainFactory(this, typeMetadataCache); tryResendMessage = msg => this.Dispatcher.TryResendMessage(msg); unregisterCallback = msg => UnRegisterCallback(msg.Id); this.siloInterceptors = new List <IGrainCallFilter>(registeredInterceptors); }
public SiloControl( ILocalSiloDetails localSiloDetails, Factory <NodeConfiguration> localConfiguration, ClusterConfiguration clusterConfiguration, DeploymentLoadPublisher deploymentLoadPublisher, Catalog catalog, GrainTypeManager grainTypeManager, ISiloPerformanceMetrics siloMetrics, IEnumerable <IProviderManager> providerManagers, ProviderManagerSystemTarget providerManagerSystemTarget, CachedVersionSelectorManager cachedVersionSelectorManager, CompatibilityDirectorManager compatibilityDirectorManager, VersionSelectorManager selectorManager, ILoggerFactory loggerFactory) : base(Constants.SiloControlId, localSiloDetails.SiloAddress, loggerFactory) { this.localSiloDetails = localSiloDetails; this.localConfiguration = localConfiguration; this.clusterConfiguration = clusterConfiguration; this.logger = loggerFactory.CreateLogger <SiloControl>(); this.deploymentLoadPublisher = deploymentLoadPublisher; this.catalog = catalog; this.grainTypeManager = grainTypeManager; this.siloMetrics = siloMetrics; this.providerManagerSystemTarget = providerManagerSystemTarget; this.providerManagers = providerManagers.ToList(); this.cachedVersionSelectorManager = cachedVersionSelectorManager; this.compatibilityDirectorManager = compatibilityDirectorManager; this.selectorManager = selectorManager; }
public SiloControl( ILocalSiloDetails localSiloDetails, DeploymentLoadPublisher deploymentLoadPublisher, Catalog catalog, GrainTypeManager grainTypeManager, ISiloPerformanceMetrics siloMetrics, CachedVersionSelectorManager cachedVersionSelectorManager, CompatibilityDirectorManager compatibilityDirectorManager, VersionSelectorManager selectorManager, IServiceProvider services, ILoggerFactory loggerFactory) : base(Constants.SiloControlId, localSiloDetails.SiloAddress, loggerFactory) { this.localSiloDetails = localSiloDetails; this.logger = loggerFactory.CreateLogger <SiloControl>(); this.deploymentLoadPublisher = deploymentLoadPublisher; this.catalog = catalog; this.grainTypeManager = grainTypeManager; this.siloMetrics = siloMetrics; this.cachedVersionSelectorManager = cachedVersionSelectorManager; this.compatibilityDirectorManager = compatibilityDirectorManager; this.selectorManager = selectorManager; this.controllables = new Dictionary <Tuple <string, string>, IControllable>(); IEnumerable <IKeyedServiceCollection <string, IControllable> > namedIControllableCollections = services.GetServices <IKeyedServiceCollection <string, IControllable> >(); foreach (IKeyedService <string, IControllable> keyedService in namedIControllableCollections.SelectMany(c => c.GetServices(services))) { IControllable controllable = keyedService.GetService(services); if (controllable != null) { this.controllables.Add(Tuple.Create(controllable.GetType().FullName, keyedService.Key), controllable); } } }
public InsideRuntimeClient( Dispatcher dispatcher, Catalog catalog, ILocalGrainDirectory directory, SiloAddress silo, ClusterConfiguration config, IConsistentRingProvider ring, GrainTypeManager typeManager, GrainFactory grainFactory, InsideRcManager rcManager) { this.dispatcher = dispatcher; MySilo = silo; this.directory = directory; ConsistentRingProvider = ring; Catalog = catalog; disposables = new List <IDisposable>(); callbacks = new ConcurrentDictionary <CorrelationId, CallbackData>(); Config = config; config.OnConfigChange("Globals/Message", () => ResponseTimeout = Config.Globals.ResponseTimeout); RuntimeClient.Current = this; this.typeManager = typeManager; this.InternalGrainFactory = grainFactory; this.RcManager = rcManager; this.InsideRcManager = rcManager; }
public InsideRuntimeClient( ILocalSiloDetails siloDetails, GrainTypeManager typeManager, TypeMetadataCache typeMetadataCache, OrleansTaskScheduler scheduler, IServiceProvider serviceProvider, MessageFactory messageFactory, Factory <ITransactionAgent> transactionAgent, ILoggerFactory loggerFactory, IOptions <SiloMessagingOptions> messagingOptions, IGrainCancellationTokenRuntime cancellationTokenRuntime, IOptions <SchedulingOptions> schedulerOptions) { this.ServiceProvider = serviceProvider; this.MySilo = siloDetails.SiloAddress; this.disposables = new List <IDisposable>(); this.callbacks = new ConcurrentDictionary <CorrelationId, CallbackData>(); this.ResponseTimeout = messagingOptions.Value.ResponseTimeout; this.typeManager = typeManager; this.messageFactory = messageFactory; this.transactionAgent = new Lazy <ITransactionAgent>(() => transactionAgent()); this.Scheduler = scheduler; this.ConcreteGrainFactory = new GrainFactory(this, typeMetadataCache); this.tryResendMessage = msg => this.Dispatcher.TryResendMessage(msg); this.unregisterCallback = msg => this.UnRegisterCallback(msg.Id); this.logger = loggerFactory.CreateLogger <InsideRuntimeClient>(); this.invokeExceptionLogger = loggerFactory.CreateLogger($"{typeof(Grain).FullName}.InvokeException"); this.loggerFactory = loggerFactory; this.messagingOptions = messagingOptions.Value; this.callbackDataLogger = loggerFactory.CreateLogger <CallbackData>(); this.timerLogger = loggerFactory.CreateLogger <SafeTimer>(); this.cancellationTokenRuntime = cancellationTokenRuntime; this.schedulingOptions = schedulerOptions.Value; }
internal Dispatcher( OrleansTaskScheduler scheduler, MessageCenter transport, Catalog catalog, IOptions <SiloMessagingOptions> messagingOptions, PlacementDirectorsManager placementDirectorsManager, ILocalGrainDirectory localGrainDirectory, IGrainLocator grainLocator, ActivationCollector activationCollector, MessageFactory messageFactory, CompatibilityDirectorManager compatibilityDirectorManager, ILoggerFactory loggerFactory, IOptions <SchedulingOptions> schedulerOptions, RuntimeMessagingTrace messagingTrace, GrainTypeManager grainTypeManager) { this.scheduler = scheduler; this.catalog = catalog; Transport = transport; this.messagingOptions = messagingOptions.Value; this.invokeWorkItemLogger = loggerFactory.CreateLogger <InvokeWorkItem>(); this.placementDirectorsManager = placementDirectorsManager; this.localGrainDirectory = localGrainDirectory; this.grainLocator = grainLocator; this.activationCollector = activationCollector; this.messageFactory = messageFactory; this.compatibilityDirectorManager = compatibilityDirectorManager; this.messagingTrace = messagingTrace; this.grainTypeManager = grainTypeManager; this.schedulingOptions = schedulerOptions.Value; logger = loggerFactory.CreateLogger <Dispatcher>(); }
internal TypeManager(SiloAddress myAddr, GrainTypeManager grainTypeManager, ISiloStatusOracle oracle, OrleansTaskScheduler scheduler, TimeSpan refreshClusterMapTimeout) : base(Constants.TypeManagerId, myAddr) { if (grainTypeManager == null) { throw new ArgumentNullException(nameof(grainTypeManager)); } if (oracle == null) { throw new ArgumentNullException(nameof(oracle)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } this.grainTypeManager = grainTypeManager; statusOracle = oracle; this.scheduler = scheduler; hasToRefreshClusterGrainInterfaceMap = true; this.refreshClusterGrainInterfaceMapTimer = new AsyncTaskSafeTimer( OnRefreshClusterMapTimer, null, TimeSpan.Zero, // Force to do it once right now refreshClusterMapTimeout); }
internal TypeManager( SiloAddress myAddr, GrainTypeManager grainTypeManager, ISiloStatusOracle oracle, OrleansTaskScheduler scheduler, TimeSpan refreshClusterMapTimeout, ImplicitStreamSubscriberTable implicitStreamSubscriberTable) : base(Constants.TypeManagerId, myAddr) { if (grainTypeManager == null) throw new ArgumentNullException(nameof(grainTypeManager)); if (oracle == null) throw new ArgumentNullException(nameof(oracle)); if (scheduler == null) throw new ArgumentNullException(nameof(scheduler)); if (implicitStreamSubscriberTable == null) throw new ArgumentNullException(nameof(implicitStreamSubscriberTable)); this.grainTypeManager = grainTypeManager; this.statusOracle = oracle; this.implicitStreamSubscriberTable = implicitStreamSubscriberTable; this.scheduler = scheduler; this.hasToRefreshClusterGrainInterfaceMap = true; this.refreshClusterGrainInterfaceMapTimer = new AsyncTaskSafeTimer( OnRefreshClusterMapTimer, null, TimeSpan.Zero, // Force to do it once right now refreshClusterMapTimeout); }
public InsideRuntimeClient( Dispatcher dispatcher, Catalog catalog, ILocalGrainDirectory directory, ClusterConfiguration config, IConsistentRingProvider ring, GrainTypeManager typeManager, TypeMetadataCache typeMetadataCache, Func<ISiloStatusOracle> siloStatusOracle, OrleansTaskScheduler scheduler) { this.dispatcher = dispatcher; MySilo = catalog.LocalSilo; this.directory = directory; ConsistentRingProvider = ring; Catalog = catalog; disposables = new List<IDisposable>(); callbacks = new ConcurrentDictionary<CorrelationId, CallbackData>(); Config = config; config.OnConfigChange("Globals/Message", () => ResponseTimeout = Config.Globals.ResponseTimeout); RuntimeClient.Current = this; this.typeManager = typeManager; this.Scheduler = scheduler; this.siloStatusOracle = new Lazy<ISiloStatusOracle>(siloStatusOracle); this.ConcreteGrainFactory = new GrainFactory(this, typeMetadataCache); RuntimeClient.Current = this; }
public InsideRuntimeClient( Dispatcher dispatcher, Catalog catalog, ILocalGrainDirectory directory, ClusterConfiguration config, IConsistentRingProvider ring, GrainTypeManager typeManager, TypeMetadataCache typeMetadataCache, Func <ISiloStatusOracle> siloStatusOracle, OrleansTaskScheduler scheduler) { this.dispatcher = dispatcher; MySilo = catalog.LocalSilo; this.directory = directory; ConsistentRingProvider = ring; Catalog = catalog; disposables = new List <IDisposable>(); callbacks = new ConcurrentDictionary <CorrelationId, CallbackData>(); Config = config; config.OnConfigChange("Globals/Message", () => ResponseTimeout = Config.Globals.ResponseTimeout); RuntimeClient.Current = this; this.typeManager = typeManager; this.Scheduler = scheduler; this.siloStatusOracle = new Lazy <ISiloStatusOracle>(siloStatusOracle); this.ConcreteGrainFactory = new GrainFactory(this, typeMetadataCache); tryResendMessage = TryResendMessage; unregisterCallback = msg => UnRegisterCallback(msg.Id); RuntimeClient.Current = this; }
public InsideRuntimeClient( ILocalSiloDetails siloDetails, GrainTypeManager typeManager, TypeMetadataCache typeMetadataCache, OrleansTaskScheduler scheduler, IServiceProvider serviceProvider, MessageFactory messageFactory, ITransactionAgent transactionAgent, ILoggerFactory loggerFactory, IOptions <SiloMessagingOptions> messagingOptions, IGrainCancellationTokenRuntime cancellationTokenRuntime, IOptions <SchedulingOptions> schedulerOptions, ApplicationRequestsStatisticsGroup appRequestStatistics) { this.ServiceProvider = serviceProvider; this.MySilo = siloDetails.SiloAddress; this.disposables = new List <IDisposable>(); this.callbacks = new ConcurrentDictionary <CorrelationId, CallbackData>(); this.typeManager = typeManager; this.messageFactory = messageFactory; this.transactionAgent = transactionAgent; this.Scheduler = scheduler; this.ConcreteGrainFactory = new GrainFactory(this, typeMetadataCache); this.logger = loggerFactory.CreateLogger <InsideRuntimeClient>(); this.invokeExceptionLogger = loggerFactory.CreateLogger($"{typeof(Grain).FullName}.InvokeException"); this.loggerFactory = loggerFactory; this.messagingOptions = messagingOptions.Value; this.cancellationTokenRuntime = cancellationTokenRuntime; this.appRequestStatistics = appRequestStatistics; this.schedulingOptions = schedulerOptions.Value; }
public IGrainMethodInvoker GetInvoker(GrainTypeManager typeManager, int interfaceId, string genericGrainType = null) { if (lastInvoker != null && interfaceId == lastInvoker.InterfaceId) return lastInvoker; var invoker = typeManager.GetInvoker(interfaceId); lastInvoker = invoker; return lastInvoker; }
public IGrainMethodInvoker GetInvoker(GrainTypeManager typeManager, int interfaceId, string genericGrainType = null) { if (lastInvoker != null && interfaceId == lastInvoker.InterfaceId) { return(lastInvoker); } var invoker = typeManager.GetInvoker(interfaceId); lastInvoker = invoker; return(lastInvoker); }
public SiloControl( Silo silo, DeploymentLoadPublisher deploymentLoadPublisher, Catalog catalog, GrainTypeManager grainTypeManager, ISiloPerformanceMetrics siloMetrics) : base(Constants.SiloControlId, silo.SiloAddress) { this.silo = silo; this.deploymentLoadPublisher = deploymentLoadPublisher; this.catalog = catalog; this.grainTypeManager = grainTypeManager; this.siloMetrics = siloMetrics; }
/// <summary> /// Constructors -- Registers Orleans system performance counters, /// plus any grain-specific activation conters that can be detected when this installer is run. /// </summary> public OrleansPerformanceCounterInstaller() { SerializationTestEnvironment.Initialize(); Trace.Listeners.Clear(); var cfg = new NodeConfiguration { TraceFilePattern = null, TraceToConsole = false }; LogManager.Initialize(cfg); consumer = new OrleansPerfCounterTelemetryConsumer(); if (GrainTypeManager.Instance == null) { var loader = new SiloAssemblyLoader(new Dictionary<string, SearchOption>()); var typeManager = new GrainTypeManager(false, loader, new RandomPlacementDefaultStrategy()); GrainTypeManager.Instance.Start(false); } }
/// <summary> /// Constructors -- Registers Orleans system performance counters, /// plus any grain-specific activation conters that can be detected when this installer is run. /// </summary> public OrleansPerformanceCounterInstaller() { SerializationManager.InitializeForTesting(); Trace.Listeners.Clear(); var cfg = new NodeConfiguration { TraceFilePattern = null, TraceToConsole = false }; LogManager.Initialize(cfg); consumer = new OrleansPerfCounterTelemetryConsumer(); if (GrainTypeManager.Instance == null) { var loader = new SiloAssemblyLoader(new Dictionary<string, SearchOption>()); var typeManager = new GrainTypeManager(false, null, loader); // We shouldn't need GrainFactory in this case GrainTypeManager.Instance.Start(false); } }
public SiloControl( ILocalSiloDetails localSiloDetails, DeploymentLoadPublisher deploymentLoadPublisher, Catalog catalog, GrainTypeManager grainTypeManager, CachedVersionSelectorManager cachedVersionSelectorManager, CompatibilityDirectorManager compatibilityDirectorManager, VersionSelectorManager selectorManager, IServiceProvider services, ILoggerFactory loggerFactory, IMessageCenter messageCenter, ActivationDirectory activationDirectory, ActivationCollector activationCollector, IAppEnvironmentStatistics appEnvironmentStatistics, IHostEnvironmentStatistics hostEnvironmentStatistics, IOptions <LoadSheddingOptions> loadSheddingOptions) : base(Constants.SiloControlId, localSiloDetails.SiloAddress, loggerFactory) { this.localSiloDetails = localSiloDetails; this.logger = loggerFactory.CreateLogger <SiloControl>(); this.deploymentLoadPublisher = deploymentLoadPublisher; this.catalog = catalog; this.grainTypeManager = grainTypeManager; this.cachedVersionSelectorManager = cachedVersionSelectorManager; this.compatibilityDirectorManager = compatibilityDirectorManager; this.selectorManager = selectorManager; this.messageCenter = messageCenter; this.activationDirectory = activationDirectory; this.activationCollector = activationCollector; this.appEnvironmentStatistics = appEnvironmentStatistics; this.hostEnvironmentStatistics = hostEnvironmentStatistics; this.loadSheddingOptions = loadSheddingOptions; this.controllables = new Dictionary <Tuple <string, string>, IControllable>(); IEnumerable <IKeyedServiceCollection <string, IControllable> > namedIControllableCollections = services.GetServices <IKeyedServiceCollection <string, IControllable> >(); foreach (IKeyedService <string, IControllable> keyedService in namedIControllableCollections.SelectMany(c => c.GetServices(services))) { IControllable controllable = keyedService.GetService(services); if (controllable != null) { this.controllables.Add(Tuple.Create(controllable.GetType().FullName, keyedService.Key), controllable); } } }
internal TypeManager( SiloAddress myAddr, GrainTypeManager grainTypeManager, ISiloStatusOracle oracle, OrleansTaskScheduler scheduler, TimeSpan refreshClusterMapInterval, ImplicitStreamSubscriberTable implicitStreamSubscriberTable, IInternalGrainFactory grainFactory, CachedVersionSelectorManager versionSelectorManager, ILoggerFactory loggerFactory) : base(Constants.TypeManagerId, myAddr, loggerFactory) { if (grainTypeManager == null) { throw new ArgumentNullException(nameof(grainTypeManager)); } if (oracle == null) { throw new ArgumentNullException(nameof(oracle)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } if (implicitStreamSubscriberTable == null) { throw new ArgumentNullException(nameof(implicitStreamSubscriberTable)); } this.logger = loggerFactory.CreateLogger <TypeManager>(); this.grainTypeManager = grainTypeManager; this.statusOracle = oracle; this.implicitStreamSubscriberTable = implicitStreamSubscriberTable; this.grainFactory = grainFactory; this.versionSelectorManager = versionSelectorManager; this.scheduler = scheduler; this.refreshClusterMapInterval = refreshClusterMapInterval; // We need this so we can place needed local activations this.grainTypeManager.SetInterfaceMapsBySilo(new Dictionary <SiloAddress, GrainInterfaceMap> { { this.Silo, grainTypeManager.GetTypeCodeMap() } }); }
public SiloControl( Silo silo, DeploymentLoadPublisher deploymentLoadPublisher, Catalog catalog, GrainTypeManager grainTypeManager, ISiloPerformanceMetrics siloMetrics, CachedVersionSelectorManager cachedVersionSelectorManager, CompatibilityDirectorManager compatibilityDirectorManager, VersionSelectorManager selectorManager) : base(Constants.SiloControlId, silo.SiloAddress) { this.silo = silo; this.deploymentLoadPublisher = deploymentLoadPublisher; this.catalog = catalog; this.grainTypeManager = grainTypeManager; this.siloMetrics = siloMetrics; this.cachedVersionSelectorManager = cachedVersionSelectorManager; this.compatibilityDirectorManager = compatibilityDirectorManager; this.selectorManager = selectorManager; }
internal TypeManager( SiloAddress myAddr, GrainTypeManager grainTypeManager, ISiloStatusOracle oracle, OrleansTaskScheduler scheduler, TimeSpan refreshClusterMapTimeout, ImplicitStreamSubscriberTable implicitStreamSubscriberTable, IInternalGrainFactory grainFactory, CachedVersionSelectorManager versionSelectorManager) : base(Constants.TypeManagerId, myAddr) { if (grainTypeManager == null) { throw new ArgumentNullException(nameof(grainTypeManager)); } if (oracle == null) { throw new ArgumentNullException(nameof(oracle)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } if (implicitStreamSubscriberTable == null) { throw new ArgumentNullException(nameof(implicitStreamSubscriberTable)); } this.grainTypeManager = grainTypeManager; this.statusOracle = oracle; this.implicitStreamSubscriberTable = implicitStreamSubscriberTable; this.grainFactory = grainFactory; this.versionSelectorManager = versionSelectorManager; this.scheduler = scheduler; this.hasToRefreshClusterGrainInterfaceMap = true; this.refreshClusterGrainInterfaceMapTimer = new AsyncTaskSafeTimer( OnRefreshClusterMapTimer, null, TimeSpan.Zero, // Force to do it once right now refreshClusterMapTimeout); }
internal static IGrainExtensionMethodInvoker TryGetExtensionInvoker(GrainTypeManager typeManager, Type handlerType) { var interfaces = GrainInterfaceUtils.GetRemoteInterfaces(handlerType).Values; if (interfaces.Count != 1) { throw new InvalidOperationException($"Extension type {handlerType.FullName} implements more than one grain interface."); } var interfaceId = GrainInterfaceUtils.GetGrainInterfaceId(interfaces.First()); var invoker = typeManager.GetInvoker(interfaceId); if (invoker != null) { return((IGrainExtensionMethodInvoker)invoker); } throw new ArgumentException( $"Provider extension handler type {handlerType} was not found in the type manager", nameof(handlerType)); }
public IGrainMethodInvoker GetInvoker(GrainTypeManager typeManager, int interfaceId, string genericGrainType = null) { // Return previous cached invoker, if applicable if (lastInvoker != null && interfaceId == lastInvoker.InterfaceId) // extension invoker returns InterfaceId==0, so this condition will never be true if an extension is installed { return(lastInvoker); } if (extensionInvoker != null && extensionInvoker.IsExtensionInstalled(interfaceId)) { // Shared invoker for all extensions installed on this grain lastInvoker = extensionInvoker; } else { // Find the specific invoker for this interface / grain type lastInvoker = typeManager.GetInvoker(interfaceId, genericGrainType); } return(lastInvoker); }
public InsideRuntimeClient( Dispatcher dispatcher, Catalog catalog, ILocalGrainDirectory directory, SiloAddress silo, ClusterConfiguration config, IConsistentRingProvider ring, GrainTypeManager typeManager) { this.dispatcher = dispatcher; MySilo = silo; this.directory = directory; ConsistentRingProvider = ring; Catalog = catalog; disposables = new List<IDisposable>(); callbacks = new ConcurrentDictionary<CorrelationId, CallbackData>(); Config = config; config.OnConfigChange("Globals/Message", () => ResponseTimeout = Config.Globals.ResponseTimeout); CallbackData.Config = Config.Globals; RuntimeClient.Current = this; this.typeManager = typeManager; }
internal TypeManager( SiloAddress myAddr, GrainTypeManager grainTypeManager, ISiloStatusOracle oracle, OrleansTaskScheduler scheduler, TimeSpan refreshClusterMapTimeout, ImplicitStreamSubscriberTable implicitStreamSubscriberTable, IInternalGrainFactory grainFactory, CachedVersionSelectorManager versionSelectorManager) : base(Constants.TypeManagerId, myAddr) { if (grainTypeManager == null) { throw new ArgumentNullException(nameof(grainTypeManager)); } if (oracle == null) { throw new ArgumentNullException(nameof(oracle)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } if (implicitStreamSubscriberTable == null) { throw new ArgumentNullException(nameof(implicitStreamSubscriberTable)); } this.grainTypeManager = grainTypeManager; this.statusOracle = oracle; this.implicitStreamSubscriberTable = implicitStreamSubscriberTable; this.grainFactory = grainFactory; this.versionSelectorManager = versionSelectorManager; this.scheduler = scheduler; this.refreshClusterMapTimeout = refreshClusterMapTimeout; }
internal Silo(SiloInitializationParameters initializationParams) { string name = initializationParams.Name; ClusterConfiguration config = initializationParams.ClusterConfig; this.initializationParams = initializationParams; SystemStatus.Current = SystemStatus.Creating; CurrentSilo = this; var startTime = DateTime.UtcNow; siloTerminatedEvent = new ManualResetEvent(false); if (!LogManager.IsInitialized) LogManager.Initialize(LocalConfig); config.OnConfigChange("Defaults/Tracing", () => LogManager.Initialize(LocalConfig, true), false); MultiClusterRegistrationStrategy.Initialize(config.Globals); StatisticsCollector.Initialize(LocalConfig); SerializationManager.Initialize(GlobalConfig.SerializationProviders, this.GlobalConfig.FallbackSerializationProvider); initTimeout = GlobalConfig.MaxJoinAttemptTime; if (Debugger.IsAttached) { initTimeout = StandardExtensions.Max(TimeSpan.FromMinutes(10), GlobalConfig.MaxJoinAttemptTime); stopTimeout = initTimeout; } var localEndpoint = this.initializationParams.SiloAddress.Endpoint; LogManager.MyIPEndPoint = localEndpoint; logger = LogManager.GetLogger("Silo", LoggerType.Runtime); logger.Info(ErrorCode.SiloGcSetting, "Silo starting with GC settings: ServerGC={0} GCLatencyMode={1}", GCSettings.IsServerGC, Enum.GetName(typeof(GCLatencyMode), GCSettings.LatencyMode)); if (!GCSettings.IsServerGC || !GCSettings.LatencyMode.Equals(GCLatencyMode.Batch)) { logger.Warn(ErrorCode.SiloGcWarning, "Note: Silo not running with ServerGC turned on or with GCLatencyMode.Batch enabled - recommend checking app config : <configuration>-<runtime>-<gcServer enabled=\"true\"> and <configuration>-<runtime>-<gcConcurrent enabled=\"false\"/>"); logger.Warn(ErrorCode.SiloGcWarning, "Note: ServerGC only kicks in on multi-core systems (settings enabling ServerGC have no effect on single-core machines)."); } logger.Info(ErrorCode.SiloInitializing, "-------------- Initializing {0} silo on host {1} MachineName {2} at {3}, gen {4} --------------", this.initializationParams.Type, LocalConfig.DNSHostName, Environment.MachineName, localEndpoint, this.initializationParams.SiloAddress.Generation); logger.Info(ErrorCode.SiloInitConfig, "Starting silo {0} with the following configuration= " + Environment.NewLine + "{1}", name, config.ToString(name)); // Configure DI using Startup type this.Services = StartupBuilder.ConfigureStartup( this.LocalConfig.StartupTypeName, (services, usingCustomServiceProvider) => { // add system types // Note: you can replace IGrainFactory with your own implementation, but // we don't recommend it, in the aspect of performance and usability services.TryAddSingleton(sp => sp); services.TryAddSingleton(this); services.TryAddSingleton(initializationParams); services.TryAddSingleton<ILocalSiloDetails>(initializationParams); services.TryAddSingleton(initializationParams.ClusterConfig); services.TryAddSingleton(initializationParams.GlobalConfig); services.TryAddTransient(sp => initializationParams.NodeConfig); services.TryAddSingleton<ITimerRegistry, TimerRegistry>(); services.TryAddSingleton<IReminderRegistry, ReminderRegistry>(); services.TryAddSingleton<IStreamProviderManager, StreamProviderManager>(); services.TryAddSingleton<GrainRuntime>(); services.TryAddSingleton<IGrainRuntime, GrainRuntime>(); services.TryAddSingleton<OrleansTaskScheduler>(); services.TryAddSingleton<GrainFactory>(sp => sp.GetService<InsideRuntimeClient>().ConcreteGrainFactory); services.TryAddExisting<IGrainFactory, GrainFactory>(); services.TryAddExisting<IInternalGrainFactory, GrainFactory>(); services.TryAddSingleton<TypeMetadataCache>(); services.TryAddSingleton<AssemblyProcessor>(); services.TryAddSingleton<ActivationDirectory>(); services.TryAddSingleton<LocalGrainDirectory>(); services.TryAddExisting<ILocalGrainDirectory, LocalGrainDirectory>(); services.TryAddSingleton<SiloStatisticsManager>(); services.TryAddSingleton<ISiloPerformanceMetrics>(sp => sp.GetRequiredService<SiloStatisticsManager>().MetricsTable); services.TryAddSingleton<SiloAssemblyLoader>(); services.TryAddSingleton<GrainTypeManager>(); services.TryAddExisting<IMessagingConfiguration, GlobalConfiguration>(); services.TryAddSingleton<MessageCenter>(); services.TryAddExisting<IMessageCenter, MessageCenter>(); services.TryAddExisting<ISiloMessageCenter, MessageCenter>(); services.TryAddSingleton<Catalog>(); services.TryAddSingleton(sp => sp.GetRequiredService<Catalog>().Dispatcher); services.TryAddSingleton<InsideRuntimeClient>(); services.TryAddExisting<IRuntimeClient, InsideRuntimeClient>(); services.TryAddExisting<ISiloRuntimeClient, InsideRuntimeClient>(); services.TryAddSingleton<MembershipFactory>(); services.TryAddSingleton<MultiClusterOracleFactory>(); services.TryAddSingleton<LocalReminderServiceFactory>(); services.TryAddSingleton<DeploymentLoadPublisher>(); services.TryAddSingleton<IMembershipTable>( sp => sp.GetRequiredService<MembershipFactory>().GetMembershipTable(sp.GetRequiredService<GlobalConfiguration>())); services.TryAddSingleton<MembershipOracle>( sp => sp.GetRequiredService<MembershipFactory>() .CreateMembershipOracle(sp.GetRequiredService<Silo>(), sp.GetRequiredService<IMembershipTable>())); services.TryAddExisting<IMembershipOracle, MembershipOracle>(); services.TryAddExisting<ISiloStatusOracle, MembershipOracle>(); services.TryAddSingleton<Func<ISiloStatusOracle>>(sp => () => sp.GetRequiredService<ISiloStatusOracle>()); services.TryAddSingleton<MultiClusterOracleFactory>(); services.TryAddSingleton<LocalReminderServiceFactory>(); services.TryAddSingleton<ClientObserverRegistrar>(); services.TryAddSingleton<SiloProviderRuntime>(); services.TryAddExisting<IStreamProviderRuntime, SiloProviderRuntime>(); services.TryAddSingleton<ImplicitStreamSubscriberTable>(); // Placement services.TryAddSingleton<PlacementDirectorsManager>(); services.TryAddSingleton<IPlacementDirector<RandomPlacement>, RandomPlacementDirector>(); services.TryAddSingleton<IPlacementDirector<PreferLocalPlacement>, PreferLocalPlacementDirector>(); services.TryAddSingleton<IPlacementDirector<StatelessWorkerPlacement>, StatelessWorkerDirector>(); services.TryAddSingleton<IPlacementDirector<ActivationCountBasedPlacement>, ActivationCountPlacementDirector>(); services.TryAddSingleton<DefaultPlacementStrategy>(); services.TryAddSingleton<ClientObserversPlacementDirector>(); services.TryAddSingleton<Func<IGrainRuntime>>(sp => () => sp.GetRequiredService<IGrainRuntime>()); services.TryAddSingleton<GrainCreator>(); if (initializationParams.GlobalConfig.UseVirtualBucketsConsistentRing) { services.TryAddSingleton<IConsistentRingProvider>( sp => new VirtualBucketsRingProvider( this.initializationParams.SiloAddress, this.initializationParams.GlobalConfig.NumVirtualBucketsConsistentRing)); } else { services.TryAddSingleton<IConsistentRingProvider>( sp => new ConsistentRingProvider(this.initializationParams.SiloAddress)); } }); this.assemblyProcessor = this.Services.GetRequiredService<AssemblyProcessor>(); this.assemblyProcessor.Initialize(); BufferPool.InitGlobalBufferPool(GlobalConfig); UnobservedExceptionsHandlerClass.SetUnobservedExceptionHandler(UnobservedExceptionHandler); AppDomain.CurrentDomain.UnhandledException += this.DomainUnobservedExceptionHandler; try { grainFactory = Services.GetRequiredService<GrainFactory>(); } catch (InvalidOperationException exc) { logger.Error(ErrorCode.SiloStartError, "Exception during Silo.Start, GrainFactory was not registered in Dependency Injection container", exc); throw; } grainTypeManager = Services.GetRequiredService<GrainTypeManager>(); // Performance metrics siloStatistics = Services.GetRequiredService<SiloStatisticsManager>(); // The scheduler scheduler = Services.GetRequiredService<OrleansTaskScheduler>(); healthCheckParticipants.Add(scheduler); runtimeClient = Services.GetRequiredService<InsideRuntimeClient>(); // Initialize the message center messageCenter = Services.GetRequiredService<MessageCenter>(); messageCenter.RerouteHandler = runtimeClient.RerouteMessage; messageCenter.SniffIncomingMessage = runtimeClient.SniffIncomingMessage; // GrainRuntime can be created only here, after messageCenter was created. grainRuntime = Services.GetRequiredService<IGrainRuntime>(); // Now the router/directory service // This has to come after the message center //; note that it then gets injected back into the message center.; localGrainDirectory = Services.GetRequiredService<LocalGrainDirectory>(); // Now the activation directory. activationDirectory = Services.GetRequiredService<ActivationDirectory>(); // Now the consistent ring provider RingProvider = Services.GetRequiredService<IConsistentRingProvider>(); // to preserve backwards compatibility, only use the service provider to inject grain dependencies if the user supplied his own // service provider, meaning that he is explicitly opting into it. catalog = Services.GetRequiredService<Catalog>(); siloStatistics.MetricsTable.Scheduler = scheduler; siloStatistics.MetricsTable.ActivationDirectory = activationDirectory; siloStatistics.MetricsTable.ActivationCollector = catalog.ActivationCollector; siloStatistics.MetricsTable.MessageCenter = messageCenter; // Now the incoming message agents incomingSystemAgent = new IncomingMessageAgent(Message.Categories.System, messageCenter, activationDirectory, scheduler, catalog.Dispatcher); incomingPingAgent = new IncomingMessageAgent(Message.Categories.Ping, messageCenter, activationDirectory, scheduler, catalog.Dispatcher); incomingAgent = new IncomingMessageAgent(Message.Categories.Application, messageCenter, activationDirectory, scheduler, catalog.Dispatcher); membershipFactory = Services.GetRequiredService<MembershipFactory>(); membershipOracle = Services.GetRequiredService<IMembershipOracle>(); SystemStatus.Current = SystemStatus.Created; StringValueStatistic.FindOrCreate(StatisticNames.SILO_START_TIME, () => LogFormatter.PrintDate(startTime)); // this will help troubleshoot production deployment when looking at MDS logs. logger.Info(ErrorCode.SiloInitializingFinished, "-------------- Started silo {0}, ConsistentHashCode {1:X} --------------", SiloAddress.ToLongString(), SiloAddress.GetConsistentHashCode()); }
public IGrainMethodInvoker GetInvoker(GrainTypeManager typeManager, int interfaceId, string genericGrainType = null) { // Return previous cached invoker, if applicable if (lastInvoker != null && interfaceId == lastInvoker.InterfaceId) // extension invoker returns InterfaceId==0, so this condition will never be true if an extension is installed return lastInvoker; if (extensionInvoker != null && extensionInvoker.IsExtensionInstalled(interfaceId)) { // Shared invoker for all extensions installed on this grain lastInvoker = extensionInvoker; } else { // Find the specific invoker for this interface / grain type lastInvoker = typeManager.GetInvoker(interfaceId, genericGrainType); } return lastInvoker; }
internal Silo(SiloInitializationParameters initializationParams, IServiceProvider services) { string name = initializationParams.Name; ClusterConfiguration config = initializationParams.ClusterConfig; this.initializationParams = initializationParams; this.SystemStatus = SystemStatus.Creating; AsynchAgent.IsStarting = true; var startTime = DateTime.UtcNow; services?.GetService <TelemetryManager>()?.AddFromConfiguration(services, LocalConfig.TelemetryConfiguration); StatisticsCollector.Initialize(LocalConfig); initTimeout = GlobalConfig.MaxJoinAttemptTime; if (Debugger.IsAttached) { initTimeout = StandardExtensions.Max(TimeSpan.FromMinutes(10), GlobalConfig.MaxJoinAttemptTime); stopTimeout = initTimeout; } var localEndpoint = this.initializationParams.SiloAddress.Endpoint; // Configure DI using Startup type if (services == null) { var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton <Silo>(this); serviceCollection.AddSingleton(initializationParams); serviceCollection.AddLegacyClusterConfigurationSupport(config); serviceCollection.Configure <SiloIdentityOptions>(options => options.SiloName = name); var hostContext = new HostBuilderContext(new Dictionary <object, object>()); DefaultSiloServices.AddDefaultServices(hostContext, serviceCollection); var applicationPartManager = hostContext.GetApplicationPartManager(); applicationPartManager.AddApplicationPartsFromAppDomain(); applicationPartManager.AddApplicationPartsFromBasePath(); services = StartupBuilder.ConfigureStartup(this.LocalConfig.StartupTypeName, serviceCollection); services.GetService <TelemetryManager>()?.AddFromConfiguration(services, LocalConfig.TelemetryConfiguration); } this.Services = services; this.Services.InitializeSiloUnobservedExceptionsHandler(); //set PropagateActivityId flag from node cofnig RequestContext.PropagateActivityId = this.initializationParams.NodeConfig.PropagateActivityId; this.loggerFactory = this.Services.GetRequiredService <ILoggerFactory>(); logger = this.loggerFactory.CreateLogger <Silo>(); logger.Info(ErrorCode.SiloGcSetting, "Silo starting with GC settings: ServerGC={0} GCLatencyMode={1}", GCSettings.IsServerGC, Enum.GetName(typeof(GCLatencyMode), GCSettings.LatencyMode)); if (!GCSettings.IsServerGC) { logger.Warn(ErrorCode.SiloGcWarning, "Note: Silo not running with ServerGC turned on - recommend checking app config : <configuration>-<runtime>-<gcServer enabled=\"true\">"); logger.Warn(ErrorCode.SiloGcWarning, "Note: ServerGC only kicks in on multi-core systems (settings enabling ServerGC have no effect on single-core machines)."); } logger.Info(ErrorCode.SiloInitializing, "-------------- Initializing {0} silo on host {1} MachineName {2} at {3}, gen {4} --------------", this.initializationParams.Type, LocalConfig.DNSHostName, Environment.MachineName, localEndpoint, this.initializationParams.SiloAddress.Generation); logger.Info(ErrorCode.SiloInitConfig, "Starting silo {0} with the following configuration= " + Environment.NewLine + "{1}", name, config.ToString(name)); var siloMessagingOptions = this.Services.GetRequiredService <IOptions <SiloMessagingOptions> >(); BufferPool.InitGlobalBufferPool(siloMessagingOptions); try { grainFactory = Services.GetRequiredService <GrainFactory>(); } catch (InvalidOperationException exc) { logger.Error(ErrorCode.SiloStartError, "Exception during Silo.Start, GrainFactory was not registered in Dependency Injection container", exc); throw; } grainTypeManager = Services.GetRequiredService <GrainTypeManager>(); // Performance metrics siloStatistics = Services.GetRequiredService <SiloStatisticsManager>(); // The scheduler scheduler = Services.GetRequiredService <OrleansTaskScheduler>(); healthCheckParticipants.Add(scheduler); runtimeClient = Services.GetRequiredService <InsideRuntimeClient>(); // Initialize the message center messageCenter = Services.GetRequiredService <MessageCenter>(); var dispatcher = this.Services.GetRequiredService <Dispatcher>(); messageCenter.RerouteHandler = dispatcher.RerouteMessage; messageCenter.SniffIncomingMessage = runtimeClient.SniffIncomingMessage; // GrainRuntime can be created only here, after messageCenter was created. grainRuntime = Services.GetRequiredService <IGrainRuntime>(); StreamProviderManager = Services.GetRequiredService <IStreamProviderManager>(); // Now the router/directory service // This has to come after the message center //; note that it then gets injected back into the message center.; localGrainDirectory = Services.GetRequiredService <LocalGrainDirectory>(); // Now the activation directory. activationDirectory = Services.GetRequiredService <ActivationDirectory>(); // Now the consistent ring provider RingProvider = Services.GetRequiredService <IConsistentRingProvider>(); catalog = Services.GetRequiredService <Catalog>(); siloStatistics.MetricsTable.Scheduler = scheduler; siloStatistics.MetricsTable.ActivationDirectory = activationDirectory; siloStatistics.MetricsTable.ActivationCollector = catalog.ActivationCollector; siloStatistics.MetricsTable.MessageCenter = messageCenter; // Now the incoming message agents var messageFactory = this.Services.GetRequiredService <MessageFactory>(); incomingSystemAgent = new IncomingMessageAgent(Message.Categories.System, messageCenter, activationDirectory, scheduler, catalog.Dispatcher, messageFactory, this.loggerFactory); incomingPingAgent = new IncomingMessageAgent(Message.Categories.Ping, messageCenter, activationDirectory, scheduler, catalog.Dispatcher, messageFactory, this.loggerFactory); incomingAgent = new IncomingMessageAgent(Message.Categories.Application, messageCenter, activationDirectory, scheduler, catalog.Dispatcher, messageFactory, this.loggerFactory); membershipOracle = Services.GetRequiredService <IMembershipOracle>(); if (!this.GlobalConfig.HasMultiClusterNetwork) { logger.Info("Skip multicluster oracle creation (no multicluster network configured)"); } else { multiClusterOracle = Services.GetRequiredService <IMultiClusterOracle>(); } this.SystemStatus = SystemStatus.Created; AsynchAgent.IsStarting = false; StringValueStatistic.FindOrCreate(StatisticNames.SILO_START_TIME, () => LogFormatter.PrintDate(startTime)); // this will help troubleshoot production deployment when looking at MDS logs. logger.Info(ErrorCode.SiloInitializingFinished, "-------------- Started silo {0}, ConsistentHashCode {1:X} --------------", SiloAddress.ToLongString(), SiloAddress.GetConsistentHashCode()); }
/// <summary> /// Create the set of Orleans counters, if they do not already exist /// </summary> /// <param name="useBruteForce">Use brute force, if necessary</param> /// <remarks>Note: Program needs to be running as Administrator to be able to register Windows perf counters.</remarks> private static void RegisterWindowsPerfCounters(bool useBruteForce) { try { if (OrleansPerfCounterManager.AreWindowsPerfCountersAvailable()) { if (!useBruteForce) { ConsoleText.WriteStatus("Orleans counters are already registered -- Use brute-force mode to re-initialize"); return; } // Delete any old perf counters UnregisterWindowsPerfCounters(true); } if (GrainTypeManager.Instance == null) { var typeManager = new GrainTypeManager(false, null); // We shouldn't need GrainFactory in this case GrainTypeManager.Instance.Start(false); } // Register perf counters OrleansPerfCounterManager.InstallCounters(); if (OrleansPerfCounterManager.AreWindowsPerfCountersAvailable()) ConsoleText.WriteStatus("Orleans counters registered successfully"); else ConsoleText.WriteError("Orleans counters are NOT registered"); } catch (Exception exc) { ConsoleText.WriteError("Error registering Orleans counters - {0}" + exc); throw; } }
internal Silo(string name, SiloType siloType, ClusterConfiguration config, ILocalDataStore keyStore) { SystemStatus.Current = SystemStatus.Creating; CurrentSilo = this; var startTime = DateTime.UtcNow; this.siloType = siloType; Name = name; siloTerminatedEvent = new ManualResetEvent(false); OrleansConfig = config; globalConfig = config.Globals; config.OnConfigChange("Defaults", () => nodeConfig = config.GetConfigurationForNode(name)); if (!TraceLogger.IsInitialized) { TraceLogger.Initialize(nodeConfig); } config.OnConfigChange("Defaults/Tracing", () => TraceLogger.Initialize(nodeConfig, true), false); ActivationData.Init(config, nodeConfig); StatisticsCollector.Initialize(nodeConfig); SerializationManager.Initialize(globalConfig.UseStandardSerializer); initTimeout = globalConfig.MaxJoinAttemptTime; if (Debugger.IsAttached) { initTimeout = StandardExtensions.Max(TimeSpan.FromMinutes(10), globalConfig.MaxJoinAttemptTime); stopTimeout = initTimeout; } IPEndPoint here = nodeConfig.Endpoint; int generation = nodeConfig.Generation; if (generation == 0) { generation = SiloAddress.AllocateNewGeneration(); nodeConfig.Generation = generation; } TraceLogger.MyIPEndPoint = here; logger = TraceLogger.GetLogger("Silo", TraceLogger.LoggerType.Runtime); logger.Info(ErrorCode.SiloGcSetting, "Silo starting with GC settings: ServerGC={0} GCLatencyMode={1}", GCSettings.IsServerGC, Enum.GetName(typeof(GCLatencyMode), GCSettings.LatencyMode)); if (!GCSettings.IsServerGC || !GCSettings.LatencyMode.Equals(GCLatencyMode.Batch)) { logger.Warn(ErrorCode.SiloGcWarning, "Note: Silo not running with ServerGC turned on or with GCLatencyMode.Batch enabled - recommend checking app config : <configuration>-<runtime>-<gcServer enabled=\"true\"> and <configuration>-<runtime>-<gcConcurrent enabled=\"false\"/>"); } logger.Info(ErrorCode.SiloInitializing, "-------------- Initializing {0} silo on host {1} MachineName {2} at {3}, gen {4} --------------", siloType, nodeConfig.DNSHostName, Environment.MachineName, here, generation); logger.Info(ErrorCode.SiloInitConfig, "Starting silo {0} with runtime Version='{1}' .NET version='{2}' Is .NET 4.5={3} OS version='{4}' Config= " + Environment.NewLine + "{5}", name, RuntimeVersion.Current, Environment.Version, ConfigUtilities.IsNet45OrNewer(), Environment.OSVersion, config.ToString(name)); if (keyStore != null) { // Re-establish reference to shared local key store in this app domain LocalDataStoreInstance.LocalDataStore = keyStore; } healthCheckParticipants = new List <IHealthCheckParticipant>(); allSiloProviders = new List <IProvider>(); BufferPool.InitGlobalBufferPool(globalConfig); PlacementStrategy.Initialize(globalConfig); UnobservedExceptionsHandlerClass.SetUnobservedExceptionHandler(UnobservedExceptionHandler); AppDomain.CurrentDomain.UnhandledException += (obj, ev) => DomainUnobservedExceptionHandler(obj, (Exception)ev.ExceptionObject); grainFactory = new GrainFactory(); typeManager = new GrainTypeManager(here.Address.Equals(IPAddress.Loopback), grainFactory); // Performance metrics siloStatistics = new SiloStatisticsManager(globalConfig, nodeConfig); config.OnConfigChange("Defaults/LoadShedding", () => siloStatistics.MetricsTable.NodeConfig = nodeConfig, false); // The scheduler scheduler = new OrleansTaskScheduler(globalConfig, nodeConfig); healthCheckParticipants.Add(scheduler); // Initialize the message center var mc = new MessageCenter(here, generation, globalConfig, siloStatistics.MetricsTable); if (nodeConfig.IsGatewayNode) { mc.InstallGateway(nodeConfig.ProxyGatewayEndpoint); } messageCenter = mc; SiloIdentity = SiloAddress.ToLongString(); // GrainRuntime can be created only here, after messageCenter was created. grainRuntime = new GrainRuntime( globalConfig.ServiceId, SiloIdentity, grainFactory, new TimerRegistry(), new ReminderRegistry(), new StreamProviderManager()); // Now the router/directory service // This has to come after the message center //; note that it then gets injected back into the message center.; localGrainDirectory = new LocalGrainDirectory(this); // Now the activation directory. // This needs to know which router to use so that it can keep the global directory in synch with the local one. activationDirectory = new ActivationDirectory(); // Now the consistent ring provider RingProvider = GlobalConfig.UseVirtualBucketsConsistentRing ? (IConsistentRingProvider) new VirtualBucketsRingProvider(SiloAddress, GlobalConfig.NumVirtualBucketsConsistentRing) : new ConsistentRingProvider(SiloAddress); Action <Dispatcher> setDispatcher; catalog = new Catalog(Constants.CatalogId, SiloAddress, Name, LocalGrainDirectory, typeManager, scheduler, activationDirectory, config, grainRuntime, out setDispatcher); var dispatcher = new Dispatcher(scheduler, messageCenter, catalog, config); setDispatcher(dispatcher); RuntimeClient.Current = new InsideRuntimeClient( dispatcher, catalog, LocalGrainDirectory, SiloAddress, config, RingProvider, typeManager, grainFactory); messageCenter.RerouteHandler = InsideRuntimeClient.Current.RerouteMessage; messageCenter.SniffIncomingMessage = InsideRuntimeClient.Current.SniffIncomingMessage; siloStatistics.MetricsTable.Scheduler = scheduler; siloStatistics.MetricsTable.ActivationDirectory = activationDirectory; siloStatistics.MetricsTable.ActivationCollector = catalog.ActivationCollector; siloStatistics.MetricsTable.MessageCenter = messageCenter; DeploymentLoadPublisher.CreateDeploymentLoadPublisher(this, globalConfig); PlacementDirectorsManager.CreatePlacementDirectorsManager(globalConfig); // Now the incoming message agents incomingSystemAgent = new IncomingMessageAgent(Message.Categories.System, messageCenter, activationDirectory, scheduler, dispatcher); incomingPingAgent = new IncomingMessageAgent(Message.Categories.Ping, messageCenter, activationDirectory, scheduler, dispatcher); incomingAgent = new IncomingMessageAgent(Message.Categories.Application, messageCenter, activationDirectory, scheduler, dispatcher); membershipFactory = new MembershipFactory(); reminderFactory = new LocalReminderServiceFactory(); SystemStatus.Current = SystemStatus.Created; StringValueStatistic.FindOrCreate(StatisticNames.SILO_START_TIME, () => TraceLogger.PrintDate(startTime)); // this will help troubleshoot production deployment when looking at MDS logs. TestHookup = new TestHookups(this); logger.Info(ErrorCode.SiloInitializingFinished, "-------------- Started silo {0}, ConsistentHashCode {1:X} --------------", SiloAddress.ToLongString(), SiloAddress.GetConsistentHashCode()); }
internal TypeManager(SiloAddress myAddr, GrainTypeManager grainTypeManager) : base(Constants.TypeManagerId, myAddr) { this.grainTypeManager = grainTypeManager; }
/// <summary> /// Create the set of Orleans counters, if they do not already exist /// </summary> /// <param name="useBruteForce">Use brute force, if necessary</param> /// <remarks>Note: Program needs to be running as Administrator to be able to register Windows perf counters.</remarks> private static void RegisterWindowsPerfCounters(bool useBruteForce) { try { if (OrleansPerfCounterTelemetryConsumer.AreWindowsPerfCountersAvailable()) { if (!useBruteForce) { ConsoleText.WriteStatus("Orleans counters are already registered -- Use brute-force mode to re-initialize"); return; } // Delete any old perf counters UnregisterWindowsPerfCounters(true); } if (GrainTypeManager.Instance == null) { var loader = new SiloAssemblyLoader(new Dictionary<string, SearchOption>()); var typeManager = new GrainTypeManager(false, loader, new RandomPlacementDefaultStrategy()); GrainTypeManager.Instance.Start(false); } // Register perf counters perfCounterConsumer.InstallCounters(); if (OrleansPerfCounterTelemetryConsumer.AreWindowsPerfCountersAvailable()) ConsoleText.WriteStatus("Orleans counters registered successfully"); else ConsoleText.WriteError("Orleans counters are NOT registered"); } catch (Exception exc) { ConsoleText.WriteError("Error registering Orleans counters - {0}" + exc); throw; } }
internal Silo(string name, SiloType siloType, ClusterConfiguration config, ILocalDataStore keyStore) { SystemStatus.Current = SystemStatus.Creating; CurrentSilo = this; var startTime = DateTime.UtcNow; this.siloType = siloType; Name = name; siloTerminatedEvent = new ManualResetEvent(false); OrleansConfig = config; globalConfig = config.Globals; config.OnConfigChange("Defaults", () => nodeConfig = config.GetConfigurationForNode(name)); if (!TraceLogger.IsInitialized) { TraceLogger.Initialize(nodeConfig); } config.OnConfigChange("Defaults/Tracing", () => TraceLogger.Initialize(nodeConfig, true), false); LimitManager.Initialize(nodeConfig); ActivationData.Init(config); StatisticsCollector.Initialize(nodeConfig); SerializationManager.Initialize(globalConfig.UseStandardSerializer); initTimeout = globalConfig.MaxJoinAttemptTime; if (Debugger.IsAttached) { initTimeout = StandardExtensions.Max(TimeSpan.FromMinutes(10), globalConfig.MaxJoinAttemptTime); stopTimeout = initTimeout; } IPEndPoint here = nodeConfig.Endpoint; int generation = nodeConfig.Generation; if (generation == 0) { generation = SiloAddress.AllocateNewGeneration(); nodeConfig.Generation = generation; } TraceLogger.MyIPEndPoint = here; logger = TraceLogger.GetLogger("Silo", TraceLogger.LoggerType.Runtime); logger.Info(ErrorCode.SiloInitializing, "-------------- Initializing {0} silo on {1} at {2}, gen {3} --------------", siloType, nodeConfig.DNSHostName, here, generation); logger.Info(ErrorCode.SiloInitConfig, "Starting silo {0} with runtime Version='{1}' Config= \n{2}", name, RuntimeVersion.Current, config.ToString(name)); if (keyStore != null) { // Re-establish reference to shared local key store in this app domain LocalDataStoreInstance.LocalDataStore = keyStore; } healthCheckParticipants = new List <IHealthCheckParticipant>(); BufferPool.InitGlobalBufferPool(globalConfig); PlacementStrategy.Initialize(globalConfig); UnobservedExceptionsHandlerClass.SetUnobservedExceptionHandler(UnobservedExceptionHandler); AppDomain.CurrentDomain.UnhandledException += (obj, ev) => DomainUnobservedExceptionHandler(obj, (Exception)ev.ExceptionObject); typeManager = new GrainTypeManager(here.Address.Equals(IPAddress.Loopback)); // Performance metrics siloStatistics = new SiloStatisticsManager(globalConfig, nodeConfig); config.OnConfigChange("Defaults/LoadShedding", () => siloStatistics.MetricsTable.NodeConfig = nodeConfig, false); // The scheduler scheduler = new OrleansTaskScheduler(globalConfig, nodeConfig); healthCheckParticipants.Add(scheduler); // Initialize the message center var mc = new MessageCenter(here, generation, globalConfig, siloStatistics.MetricsTable); if (nodeConfig.IsGatewayNode) { mc.InstallGateway(nodeConfig.ProxyGatewayEndpoint); } messageCenter = mc; // Now the router/directory service // This has to come after the message center //; note that it then gets injected back into the message center.; localGrainDirectory = new LocalGrainDirectory(this); // Now the activation directory. // This needs to know which router to use so that it can keep the global directory in synch with the local one. activationDirectory = new ActivationDirectory(); // Now the consistent ring provider RingProvider = GlobalConfig.UseVirtualBucketsConsistentRing ? (IConsistentRingProvider) new VirtualBucketsRingProvider(SiloAddress, GlobalConfig.NumVirtualBucketsConsistentRing) : new ConsistentRingProvider(SiloAddress); Action <Dispatcher> setDispatcher; catalog = new Catalog(Constants.CatalogId, SiloAddress, Name, LocalGrainDirectory, typeManager, scheduler, activationDirectory, config, out setDispatcher); var dispatcher = new Dispatcher(scheduler, messageCenter, catalog, config); setDispatcher(dispatcher); RuntimeClient.Current = new InsideRuntimeClient( dispatcher, catalog, LocalGrainDirectory, SiloAddress, config, RingProvider, typeManager); messageCenter.RerouteHandler = InsideRuntimeClient.Current.RerouteMessage; messageCenter.SniffIncomingMessage = InsideRuntimeClient.Current.SniffIncomingMessage; messageCenter.ClientDropHandler = grainIds => { catalog.DeleteGrainsLocal(grainIds).Ignore(); scheduler.RunOrQueueAction(() => { // Consider: batch delete foreach (var id in grainIds) { LocalGrainDirectory.DeleteGrain(id).Ignore(); } }, catalog.SchedulingContext); }; siloStatistics.MetricsTable.Scheduler = scheduler; siloStatistics.MetricsTable.ActivationDirectory = activationDirectory; siloStatistics.MetricsTable.ActivationCollector = catalog.ActivationCollector; siloStatistics.MetricsTable.MessageCenter = messageCenter; DeploymentLoadPublisher.CreateDeploymentLoadPublisher(this, globalConfig); PlacementDirectorsManager.CreatePlacementDirectorsManager(globalConfig); // Now the incoming message agents incomingSystemAgent = new IncomingMessageAgent(Message.Categories.System, messageCenter, activationDirectory, scheduler, dispatcher); incomingPingAgent = new IncomingMessageAgent(Message.Categories.Ping, messageCenter, activationDirectory, scheduler, dispatcher); incomingAgent = new IncomingMessageAgent(Message.Categories.Application, messageCenter, activationDirectory, scheduler, dispatcher); membershipFactory = new MembershipFactory(); reminderFactory = new LocalReminderServiceFactory(); SystemStatus.Current = SystemStatus.Created; StringValueStatistic.FindOrCreate(StatisticNames.SILO_START_TIME, () => TraceLogger.PrintDate(startTime)); // this will help troubleshoot production deployment when looking at MDS logs. TestHookup = new TestHookups(this); logger.Info(ErrorCode.SiloInitializingFinished, "-------------- Started silo {0}, ConsistentHashCode {1:X} --------------", SiloAddress.ToLongString(), SiloAddress.GetConsistentHashCode()); }
public Catalog( SiloInitializationParameters siloInitializationParameters, ILocalGrainDirectory grainDirectory, GrainTypeManager typeManager, OrleansTaskScheduler scheduler, ActivationDirectory activationDirectory, ClusterConfiguration config, GrainCreator grainCreator, NodeConfiguration nodeConfig, ISiloMessageCenter messageCenter, PlacementDirectorsManager placementDirectorsManager) : base(Constants.CatalogId, messageCenter.MyAddress) { LocalSilo = siloInitializationParameters.SiloAddress; localSiloName = siloInitializationParameters.Name; directory = grainDirectory; activations = activationDirectory; this.scheduler = scheduler; GrainTypeManager = typeManager; collectionNumber = 0; destroyActivationsNumber = 0; this.grainCreator = grainCreator; this.nodeConfig = nodeConfig; logger = LogManager.GetLogger("Catalog", Runtime.LoggerType.Runtime); this.config = config.Globals; ActivationCollector = new ActivationCollector(config); this.Dispatcher = new Dispatcher(scheduler, messageCenter, this, config, placementDirectorsManager); GC.GetTotalMemory(true); // need to call once w/true to ensure false returns OK value config.OnConfigChange("Globals/Activation", () => scheduler.RunOrQueueAction(Start, SchedulingContext), false); IntValueStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_COUNT, () => activations.Count); activationsCreated = CounterStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_CREATED); activationsDestroyed = CounterStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_DESTROYED); activationsFailedToActivate = CounterStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_FAILED_TO_ACTIVATE); collectionCounter = CounterStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_COLLECTION_NUMBER_OF_COLLECTIONS); inProcessRequests = IntValueStatistic.FindOrCreate(StatisticNames.MESSAGING_PROCESSING_ACTIVATION_DATA_ALL, () => { long counter = 0; lock (activations) { foreach (var activation in activations) { ActivationData data = activation.Value; counter += data.GetRequestCount(); } } return counter; }); maxWarningRequestProcessingTime = this.config.ResponseTimeout.Multiply(5); maxRequestProcessingTime = this.config.MaxRequestProcessingTime; }
internal Catalog( GrainId grainId, SiloAddress silo, string siloName, ILocalGrainDirectory grainDirectory, GrainTypeManager typeManager, OrleansTaskScheduler scheduler, ActivationDirectory activationDirectory, ClusterConfiguration config, IGrainRuntime grainRuntime, out Action<Dispatcher> setDispatcher) : base(grainId, silo) { LocalSilo = silo; localSiloName = siloName; directory = grainDirectory; activations = activationDirectory; this.scheduler = scheduler; GrainTypeManager = typeManager; this.grainRuntime = grainRuntime; collectionNumber = 0; destroyActivationsNumber = 0; logger = TraceLogger.GetLogger("Catalog", TraceLogger.LoggerType.Runtime); this.config = config.Globals; setDispatcher = d => dispatcher = d; ActivationCollector = new ActivationCollector(config); GC.GetTotalMemory(true); // need to call once w/true to ensure false returns OK value config.OnConfigChange("Globals/Activation", () => scheduler.RunOrQueueAction(Start, SchedulingContext), false); IntValueStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_COUNT, () => activations.Count); activationsCreated = CounterStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_CREATED); activationsDestroyed = CounterStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_DESTROYED); activationsFailedToActivate = CounterStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_FAILED_TO_ACTIVATE); collectionCounter = CounterStatistic.FindOrCreate(StatisticNames.CATALOG_ACTIVATION_COLLECTION_NUMBER_OF_COLLECTIONS); inProcessRequests = IntValueStatistic.FindOrCreate(StatisticNames.MESSAGING_PROCESSING_ACTIVATION_DATA_ALL, () => { long counter = 0; lock (activations) { foreach (var activation in activations) { ActivationData data = activation.Value; counter += data.GetRequestCount(); } } return counter; }); }