public ClusterGrainDirectory(LocalGrainDirectory r, GrainId grainId, string clusterId, bool lowPriority) : base(grainId, r.MyAddress, lowPriority) { this.router = r; this.clusterId = clusterId; this.logger = r.Logger; }
private static readonly TimeSpan RETRY_DELAY = TimeSpan.FromSeconds(5); // Pause 5 seconds between forwards to let the membership directory settle down internal RemoteGrainDirectory(LocalGrainDirectory r, GrainId id) : base(id, r.MyAddress) { router = r; partition = r.DirectoryPartition; logger = TraceLogger.GetLogger("Orleans.GrainDirectory.CacheValidator", TraceLogger.LoggerType.Runtime); }
internal GlobalSingleInstanceActivationMaintainer(LocalGrainDirectory router, Logger logger, GlobalConfiguration config) { this.router = router; this.logger = logger; this.period = config.GlobalSingleInstanceRetryInterval; logger.Verbose("GSIP:M GlobalSingleInstanceActivationMaintainer Started, Period = {0}", period); }
internal GrainDirectoryHandoffManager(LocalGrainDirectory localDirectory, GlobalConfiguration config) { logger = TraceLogger.GetLogger(this.GetType().FullName); this.localDirectory = localDirectory; directoryPartitionsMap = new Dictionary<SiloAddress, GrainDirectoryPartition>(); silosHoldingMyPartition = new List<SiloAddress>(); lastPromise = new Dictionary<SiloAddress, Task>(); }
internal static AdaptiveDirectoryCacheMaintainer CreateGrainDirectoryCacheMaintainer( LocalGrainDirectory router, IGrainDirectoryCache cache, IInternalGrainFactory grainFactory, ILoggerFactory loggerFactory) { var adaptiveCache = cache as AdaptiveGrainDirectoryCache; return(adaptiveCache != null ? new AdaptiveDirectoryCacheMaintainer(router, adaptiveCache, grainFactory, loggerFactory) : null); }
internal static AsynchAgent CreateGrainDirectoryCacheMaintainer( LocalGrainDirectory router, IGrainDirectoryCache <TValue> cache, Func <List <ActivationAddress>, TValue> updateFunc, IInternalGrainFactory grainFactory) { var adaptiveCache = cache as AdaptiveGrainDirectoryCache <TValue>; return(adaptiveCache != null ? new AdaptiveDirectoryCacheMaintainer <TValue>(router, adaptiveCache, updateFunc, grainFactory) : null); }
public ClusterGrainDirectory( LocalGrainDirectory r, GrainId grainId, string clusterId, IInternalGrainFactory grainFactory, IMultiClusterOracle multiClusterOracle) : base(grainId, r.MyAddress) { this.router = r; this.clusterId = clusterId; this.grainFactory = grainFactory; this.logger = r.Logger; this.multiClusterOracle = multiClusterOracle; }
internal static DedicatedAsynchAgent CreateGrainDirectoryCacheMaintainer( LocalGrainDirectory router, IGrainDirectoryCache cache, IInternalGrainFactory grainFactory, ExecutorService executorService, ILoggerFactory loggerFactory) { var adaptiveCache = cache as AdaptiveGrainDirectoryCache; return(adaptiveCache != null ? new AdaptiveDirectoryCacheMaintainer(router, adaptiveCache, grainFactory, executorService, loggerFactory) : null); }
private long lastNumHits; // for stats internal AdaptiveDirectoryCacheMaintainer( LocalGrainDirectory router, AdaptiveGrainDirectoryCache <TValue> cache, Func <List <ActivationAddress>, TValue> updateFunc) { this.updateFunc = updateFunc; this.router = router; this.cache = cache; lastNumAccesses = 0; lastNumHits = 0; OnFault = FaultBehavior.RestartOnFault; }
internal GrainDirectoryHandoffManager( LocalGrainDirectory localDirectory, ISiloStatusOracle siloStatusOracle, IInternalGrainFactory grainFactory, Factory <GrainDirectoryPartition> createPartion) { logger = LogManager.GetLogger(this.GetType().FullName); this.localDirectory = localDirectory; this.siloStatusOracle = siloStatusOracle; this.grainFactory = grainFactory; this.createPartion = createPartion; directoryPartitionsMap = new Dictionary <SiloAddress, GrainDirectoryPartition>(); silosHoldingMyPartition = new List <SiloAddress>(); lastPromise = new Dictionary <SiloAddress, Task>(); }
private long lastNumHits; // for stats internal AdaptiveDirectoryCacheMaintainer( LocalGrainDirectory router, AdaptiveGrainDirectoryCache cache, IInternalGrainFactory grainFactory, ILoggerFactory loggerFactory) : base(nameSuffix: null, loggerFactory) { this.grainFactory = grainFactory; this.router = router; this.cache = cache; lastNumAccesses = 0; lastNumHits = 0; OnFault = FaultBehavior.RestartOnFault; }
public ClusterGrainDirectory( ILocalSiloDetails localSiloDetails, LocalGrainDirectory localGrainDirectory, GrainId grainId, string clusterId, IInternalGrainFactory grainFactory, IMultiClusterOracle multiClusterOracle, ILoggerFactory loggerFactory) : base(grainId, localSiloDetails.SiloAddress, loggerFactory) { this.localGrainDirectory = localGrainDirectory; this.clusterId = clusterId; this.grainFactory = grainFactory; this.logger = loggerFactory.CreateLogger <ClusterGrainDirectory>(); this.multiClusterOracle = multiClusterOracle; }
public GlobalSingleInstanceActivationMaintainer( LocalGrainDirectory router, Logger logger, GlobalConfiguration config, IInternalGrainFactory grainFactory, IMultiClusterOracle multiClusterOracle) { this.router = router; this.logger = logger; this.grainFactory = grainFactory; this.config = config; this.multiClusterOracle = multiClusterOracle; this.period = config.GlobalSingleInstanceRetryInterval; logger.Verbose("GSIP:M GlobalSingleInstanceActivationMaintainer Started, Period = {0}", period); }
internal GrainDirectoryHandoffManager( LocalGrainDirectory localDirectory, ISiloStatusOracle siloStatusOracle, IInternalGrainFactory grainFactory, Factory <GrainDirectoryPartition> createPartion, ILoggerFactory loggerFactory) { logger = new LoggerWrapper <GrainDirectoryHandoffManager>(loggerFactory); this.localDirectory = localDirectory; this.siloStatusOracle = siloStatusOracle; this.grainFactory = grainFactory; this.createPartion = createPartion; directoryPartitionsMap = new Dictionary <SiloAddress, GrainDirectoryPartition>(); silosHoldingMyPartition = new List <SiloAddress>(); lastPromise = new Dictionary <SiloAddress, Task>(); }
public GlobalSingleInstanceRegistrar( LocalGrainDirectory localDirectory, Factory <string, Logger> loggerFactory, GlobalSingleInstanceActivationMaintainer gsiActivationMaintainer, GlobalConfiguration config, IInternalGrainFactory grainFactory, IMultiClusterOracle multiClusterOracle) { this.directoryPartition = localDirectory.DirectoryPartition; this.logger = loggerFactory(nameof(GlobalSingleInstanceRegistrar)); this.gsiActivationMaintainer = gsiActivationMaintainer; this.numRetries = config.GlobalSingleInstanceNumberRetries; this.grainFactory = grainFactory; this.multiClusterOracle = multiClusterOracle; this.hasMultiClusterNetwork = config.HasMultiClusterNetwork; this.clusterId = config.ClusterId; }
public GlobalSingleInstanceRegistrar( LocalGrainDirectory localDirectory, ILogger <GlobalSingleInstanceRegistrar> logger, GlobalSingleInstanceActivationMaintainer gsiActivationMaintainer, IInternalGrainFactory grainFactory, IMultiClusterOracle multiClusterOracle, ILocalSiloDetails siloDetails, IOptions <MultiClusterOptions> multiClusterOptions) { this.directoryPartition = localDirectory.DirectoryPartition; this.logger = logger; this.gsiActivationMaintainer = gsiActivationMaintainer; this.numRetries = multiClusterOptions.Value.GlobalSingleInstanceNumberRetries; this.grainFactory = grainFactory; this.multiClusterOracle = multiClusterOracle; this.hasMultiClusterNetwork = multiClusterOptions.Value.HasMultiClusterNetwork; this.clusterId = siloDetails.ClusterId; }
private long lastNumHits; // for stats internal AdaptiveDirectoryCacheMaintainer( LocalGrainDirectory router, AdaptiveGrainDirectoryCache <TValue> cache, Func <List <ActivationAddress>, TValue> updateFunc, IInternalGrainFactory grainFactory, ExecutorService executorService, ILoggerFactory loggerFactory) : base(executorService, loggerFactory) { this.updateFunc = updateFunc; this.grainFactory = grainFactory; this.router = router; this.cache = cache; lastNumAccesses = 0; lastNumHits = 0; OnFault = FaultBehavior.RestartOnFault; }
public GlobalSingleInstanceActivationMaintainer( LocalGrainDirectory router, ILogger logger, IInternalGrainFactory grainFactory, IMultiClusterOracle multiClusterOracle, ExecutorService executorService, ILocalSiloDetails siloDetails, IOptions <MultiClusterOptions> multiClusterOptions, ILoggerFactory loggerFactory) : base(executorService, loggerFactory) { this.router = router; this.logger = logger; this.grainFactory = grainFactory; this.multiClusterOracle = multiClusterOracle; this.siloDetails = siloDetails; this.multiClusterOptions = multiClusterOptions.Value; this.period = multiClusterOptions.Value.GlobalSingleInstanceRetryInterval; logger.Debug("GSIP:M GlobalSingleInstanceActivationMaintainer Started, Period = {0}", period); }
internal static DedicatedAsynchAgent CreateGrainDirectoryCacheMaintainer( ILocalSiloDetails localSiloDetails, LocalGrainDirectory localGrainDirectory, IGrainDirectoryCache <TValue> cache, Func <List <ActivationAddress>, TValue> updateFunc, IInternalGrainFactory grainFactory, ExecutorService executorService, ILoggerFactory loggerFactory) { var adaptiveCache = cache as AdaptiveGrainDirectoryCache <TValue>; if (adaptiveCache is null) { return(null); } return(new AdaptiveDirectoryCacheMaintainer <TValue>( localSiloDetails, localGrainDirectory, adaptiveCache, updateFunc, grainFactory, executorService, loggerFactory)); }
public static void InitializeGrainDirectoryManager(LocalGrainDirectory router) { Instance = new RegistrarManager(); Instance.Register <ClusterLocalRegistration>(new ClusterLocalRegistrar(router.DirectoryPartition)); }
public ClusterGrainDirectory(LocalGrainDirectory r, GrainId grainId, string clusterId) : base(grainId, r.MyAddress) { this.router = r; this.clusterId = clusterId; this.logger = r.Logger; }
public static void InitializeGrainDirectoryManager(LocalGrainDirectory router, int numRetriesForGSI) { Instance = new RegistrarManager(); Instance.Register<ClusterLocalRegistration>(new ClusterLocalRegistrar(router.DirectoryPartition)); Instance.Register<GlobalSingleInstanceRegistration>(new GlobalSingleInstanceRegistrar(router.DirectoryPartition, router.Logger, router.GsiActivationMaintainer, numRetriesForGSI)); }
internal static AsynchAgent CreateGrainDirectoryCacheMaintainer(LocalGrainDirectory router, IGrainDirectoryCache <TValue> cache) { return(cache is AdaptiveGrainDirectoryCache <TValue>? new AdaptiveDirectoryCacheMaintainer <TValue>(router, cache) : null); }
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 ClusterLocalRegistrar(LocalGrainDirectory directory) { directoryPartition = directory.DirectoryPartition; }