public MessageCenter(SiloInitializationParameters silo, NodeConfiguration nodeConfig, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null) { this.Initialize(silo.SiloAddress.Endpoint, nodeConfig.Generation, config, metrics); if (nodeConfig.IsGatewayNode) { this.InstallGateway(nodeConfig.ProxyGatewayEndpoint); } }
private void Init() { Globals = new GlobalConfiguration(); Defaults = new NodeConfiguration(); Overrides = new Dictionary<string, NodeConfiguration>(); overrideXml = new Dictionary<string, string>(); SourceFile = ""; IsRunningAsUnitTest = false; }
internal SiloPerformanceMetrics(RuntimeStatisticsGroup runtime, NodeConfiguration cfg = null) { runtimeStats = runtime; reportFrequency = TimeSpan.Zero; overloadLatched = false; overloadValue = false; NodeConfig = cfg ?? new NodeConfiguration(); StringValueStatistic.FindOrCreate(StatisticNames.RUNTIME_IS_OVERLOADED, () => IsOverloaded.ToString()); }
/// <summary>Creates a new silo in a remote app domain and returns a handle to it.</summary> public static SiloHandle Create(string siloName, Silo.SiloType type, ClusterConfiguration config, NodeConfiguration nodeConfiguration, Dictionary<string, GeneratedAssembly> additionalAssemblies) { AppDomainSetup setup = GetAppDomainSetupInfo(); var appDomain = AppDomain.CreateDomain(siloName, null, setup); // Load each of the additional assemblies. AppDomainSiloHost.CodeGeneratorOptimizer optimizer = null; foreach (var assembly in additionalAssemblies.Where(asm => asm.Value != null)) { if (optimizer == null) { optimizer = (AppDomainSiloHost.CodeGeneratorOptimizer) appDomain.CreateInstanceAndUnwrap( typeof(AppDomainSiloHost.CodeGeneratorOptimizer).Assembly.FullName, typeof(AppDomainSiloHost.CodeGeneratorOptimizer).FullName, false, BindingFlags.Default, null, null, CultureInfo.CurrentCulture, new object[] { }); } optimizer.AddCachedAssembly(assembly.Key, assembly.Value); } var args = new object[] { siloName, type, config }; var siloHost = (AppDomainSiloHost)appDomain.CreateInstanceAndUnwrap( typeof(AppDomainSiloHost).Assembly.FullName, typeof(AppDomainSiloHost).FullName, false, BindingFlags.Default, null, args, CultureInfo.CurrentCulture, new object[] { }); appDomain.UnhandledException += ReportUnobservedException; appDomain.DoCallBack(RegisterPerfCountersTelemetryConsumer); siloHost.Start(); var retValue = new AppDomainSiloHandle { Name = siloName, SiloHost = siloHost, NodeConfiguration = nodeConfiguration, SiloAddress = siloHost.SiloAddress, Type = type, AppDomain = appDomain, additionalAssemblies = additionalAssemblies, #if !NETSTANDARD_TODO AppDomainTestHook = siloHost.AppDomainTestHook, #endif }; retValue.ImportGeneratedAssemblies(); return retValue; }
internal SiloStatisticsManager(GlobalConfiguration globalConfig, NodeConfiguration nodeConfig) { MessagingStatisticsGroup.Init(true); MessagingProcessingStatisticsGroup.Init(); NetworkingStatisticsGroup.Init(true); ApplicationRequestsStatisticsGroup.Init(globalConfig.ResponseTimeout); SchedulerStatisticsGroup.Init(); StorageStatisticsGroup.Init(); runtimeStats = new RuntimeStatisticsGroup(); logStatistics = new LogStatistics(nodeConfig.StatisticsLogWriteInterval, true); MetricsTable = new SiloPerformanceMetrics(runtimeStats, nodeConfig); perfCountersPublisher = new PerfCountersStatistics(nodeConfig.StatisticsPerfCountersWriteInterval); }
/// <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); } }
/// <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); } }
public void ApplicationRequestsStatisticsGroup_Perf() { var config = new NodeConfiguration(); config.StatisticsCollectionLevel = StatisticsLevel.Info; StatisticsCollector.Initialize(config); ApplicationRequestsStatisticsGroup.Init(TimeSpan.FromSeconds(30)); const long nIterations = 10000000; const int nValues = 1000; var rand = new Random(); var times = new TimeSpan[nValues]; for (int i = 0; i < 1000; i++) { times[i] = TimeSpan.FromMilliseconds(rand.Next(30000)); } Stopwatch sw = Stopwatch.StartNew(); var tasks = new List<Task>(); for (int j = 0; j < 10; j++) { //int capture = j; tasks.Add(Task.Run(() => { //long tenPercent = nIterations/10; for (long i = 0; i < nIterations; i++) { ApplicationRequestsStatisticsGroup.OnAppRequestsEnd(times[i % nValues]); //if (i % tenPercent == 0) // Console.WriteLine("Thread {0}: {1}% done", capture, i * 100 / nIterations); } })); } Task.WhenAll(tasks).Wait(); sw.Stop(); Console.WriteLine("Done."); Console.WriteLine(sw.ElapsedMilliseconds); }
internal async Task SetSiloMetricsTableDataManager(Silo silo, NodeConfiguration nodeConfig) { bool useAzureTable; bool useExternalMetricsProvider = ShouldUseExternalMetricsProvider(silo, nodeConfig, out useAzureTable); if (useExternalMetricsProvider) { var extType = nodeConfig.StatisticsProviderName; var metricsProvider = silo.StatisticsProviderManager.GetProvider(extType); var metricsDataPublisher = metricsProvider as ISiloMetricsDataPublisher; if (metricsDataPublisher == null) { var msg = String.Format("Trying to create {0} as a silo metrics publisher, but the provider is not available." + " Expected type = {1} Actual type = {2}", extType, typeof(IStatisticsPublisher), metricsProvider.GetType()); throw new InvalidOperationException(msg); } var configurableMetricsDataPublisher = metricsDataPublisher as IConfigurableSiloMetricsDataPublisher; if (configurableMetricsDataPublisher != null) { var gateway = nodeConfig.IsGatewayNode ? nodeConfig.ProxyGatewayEndpoint : null; configurableMetricsDataPublisher.AddConfiguration( silo.GlobalConfig.DeploymentId, true, silo.Name, silo.SiloAddress, gateway, nodeConfig.DNSHostName); } MetricsTable.MetricsDataPublisher = metricsDataPublisher; } else if (useAzureTable) { // Hook up to publish silo metrics to Azure storage table var gateway = nodeConfig.IsGatewayNode ? nodeConfig.ProxyGatewayEndpoint : null; var metricsDataPublisher = AssemblyLoader.LoadAndCreateInstance<ISiloMetricsDataPublisher>(Constants.ORLEANS_AZURE_UTILS_DLL, logger); await metricsDataPublisher.Init(silo.GlobalConfig.DeploymentId, silo.GlobalConfig.DataConnectionString, silo.SiloAddress, silo.Name, gateway, nodeConfig.DNSHostName); MetricsTable.MetricsDataPublisher = metricsDataPublisher; } // else no metrics }
/// <summary> /// Returns the configuration for a given silo. /// </summary> /// <param name="name">Silo name.</param> /// <returns>NodeConfiguration associated with the specified silo.</returns> public NodeConfiguration GetConfigurationForNode(string name) { NodeConfiguration n; if (Overrides.TryGetValue(name, out n)) return n; n = new NodeConfiguration(Defaults) {SiloName = name}; InitNodeSettingsFromGlobals(n); Overrides[name] = n; return n; }
private void InitNodeSettingsFromGlobals(NodeConfiguration n) { if (n.Endpoint.Equals(this.PrimaryNode)) n.IsPrimaryNode = true; if (Globals.SeedNodes.Contains(n.Endpoint)) n.IsSeedNode = true; }
private void CalculateOverrides() { if (Globals.LivenessEnabled && Globals.LivenessType == GlobalConfiguration.LivenessProviderType.NotSpecified) { if (Globals.UseSqlSystemStore) { Globals.LivenessType = GlobalConfiguration.LivenessProviderType.SqlServer; } else if (Globals.UseAzureSystemStore) { Globals.LivenessType = GlobalConfiguration.LivenessProviderType.AzureTable; } else if (Globals.UseZooKeeperSystemStore) { Globals.LivenessType = GlobalConfiguration.LivenessProviderType.ZooKeeper; } else { Globals.LivenessType = GlobalConfiguration.LivenessProviderType.MembershipTableGrain; } } if (Globals.UseMockReminderTable) { Globals.SetReminderServiceType(GlobalConfiguration.ReminderServiceProviderType.MockTable); } else if (Globals.ReminderServiceType == GlobalConfiguration.ReminderServiceProviderType.NotSpecified) { if (Globals.UseSqlSystemStore) { Globals.SetReminderServiceType(GlobalConfiguration.ReminderServiceProviderType.SqlServer); } else if (Globals.UseAzureSystemStore) { Globals.SetReminderServiceType(GlobalConfiguration.ReminderServiceProviderType.AzureTable); } else if (Globals.UseZooKeeperSystemStore) { Globals.SetReminderServiceType(GlobalConfiguration.ReminderServiceProviderType.Disabled); } else { Globals.SetReminderServiceType(GlobalConfiguration.ReminderServiceProviderType.ReminderTableGrain); } } foreach (var p in overrideXml) { var n = new NodeConfiguration(Defaults); n.Load(ParseXml(new StringReader(p.Value))); InitNodeSettingsFromGlobals(n); Overrides[n.SiloName] = n; } }
private SiloHandle LoadSiloInNewAppDomain(string siloName, Silo.SiloType type, ClusterConfiguration config, NodeConfiguration nodeConfiguration) { return AppDomainSiloHandle.Create(siloName, type, config, nodeConfiguration, this.additionalAssemblies); }
public void ServerConfig_TraceFileName_Blank() { var cfg = new NodeConfiguration(); cfg.TraceFileName = string.Empty; output.WriteLine(cfg.ToString()); cfg.TraceFileName = null; output.WriteLine(cfg.ToString()); }
public static SiloHandle StartOrleansSilo(TestCluster cluster, Silo.SiloType type, ClusterConfiguration clusterConfig, NodeConfiguration nodeConfig) { if (cluster == null) throw new ArgumentNullException(nameof(cluster)); var siloName = nodeConfig.SiloName; cluster.WriteLog("Starting a new silo in app domain {0} with config {1}", siloName, clusterConfig.ToString(siloName)); AppDomain appDomain; Silo silo = cluster.LoadSiloInNewAppDomain(siloName, type, clusterConfig, out appDomain); silo.Start(); SiloHandle retValue = new SiloHandle { Name = siloName, Silo = silo, NodeConfiguration = nodeConfig, Endpoint = silo.SiloAddress.Endpoint, AppDomain = appDomain, }; cluster.ImportGeneratedAssemblies(retValue); return retValue; }
public OrleansTaskScheduler(GlobalConfiguration globalConfig, NodeConfiguration config) : this(config.MaxActiveThreads, config.DelayWarningThreshold, config.ActivationSchedulingQuantum, config.TurnWarningLengthThreshold, config.InjectMoreWorkerThreads, config.LimitManager.GetLimit(LimitNames.LIMIT_MAX_PENDING_ITEMS)) { }
/// <summary> /// Obtains the configuration for a given silo. /// </summary> /// <param name="siloName">Silo name.</param> /// <param name="siloNode">NodeConfiguration associated with the specified silo.</param> /// <returns>true if node was found</returns> public bool TryGetNodeConfigurationForSilo(string siloName, out NodeConfiguration siloNode) { return Overrides.TryGetValue(siloName, out siloNode); }
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; }
public SiloAssemblyLoader(NodeConfiguration nodeConfig) : this(nodeConfig.AdditionalAssemblyDirectories) { }
/// <summary> /// Creates a configuration node for a given silo. /// </summary> /// <param name="siloName">Silo name.</param> /// <returns>NodeConfiguration associated with the specified silo.</returns> public NodeConfiguration CreateNodeConfigurationForSilo(string siloName) { var siloNode = new NodeConfiguration(Defaults) { SiloName = siloName }; InitNodeSettingsFromGlobals(siloNode); Overrides[siloName] = siloNode; return siloNode; }
internal void Start(NodeConfiguration config) { perfCountersPublisher.Start(); logStatistics.Start(); runtimeStats.Start(); // Start performance metrics publisher MetricsTable.MetricsTableWriteInterval = config.StatisticsMetricsTableWriteInterval; }
public NodeConfiguration(NodeConfiguration other) { creationTimestamp = other.creationTimestamp; SiloName = other.SiloName; HostNameOrIPAddress = other.HostNameOrIPAddress; DNSHostName = other.DNSHostName; Port = other.Port; Generation = other.Generation; AddressType = other.AddressType; ProxyGatewayEndpoint = other.ProxyGatewayEndpoint; MaxActiveThreads = other.MaxActiveThreads; DelayWarningThreshold = other.DelayWarningThreshold; ActivationSchedulingQuantum = other.ActivationSchedulingQuantum; TurnWarningLengthThreshold = other.TurnWarningLengthThreshold; InjectMoreWorkerThreads = other.InjectMoreWorkerThreads; LoadSheddingEnabled = other.LoadSheddingEnabled; LoadSheddingLimit = other.LoadSheddingLimit; DefaultTraceLevel = other.DefaultTraceLevel; TraceLevelOverrides = new List<Tuple<string, Severity>>(other.TraceLevelOverrides); TraceToConsole = other.TraceToConsole; TraceFilePattern = other.TraceFilePattern; TraceFileName = other.TraceFileName; LargeMessageWarningThreshold = other.LargeMessageWarningThreshold; PropagateActivityId = other.PropagateActivityId; BulkMessageLimit = other.BulkMessageLimit; StatisticsProviderName = other.StatisticsProviderName; StatisticsMetricsTableWriteInterval = other.StatisticsMetricsTableWriteInterval; StatisticsPerfCountersWriteInterval = other.StatisticsPerfCountersWriteInterval; StatisticsLogWriteInterval = other.StatisticsLogWriteInterval; StatisticsWriteLogStatisticsToTable = other.StatisticsWriteLogStatisticsToTable; StatisticsCollectionLevel = other.StatisticsCollectionLevel; LimitManager = new LimitManager(other.LimitManager); // Shallow copy Subnet = other.Subnet; MinDotNetThreadPoolSize = other.MinDotNetThreadPoolSize; Expect100Continue = other.Expect100Continue; DefaultConnectionLimit = other.DefaultConnectionLimit; UseNagleAlgorithm = other.UseNagleAlgorithm; StartupTypeName = other.StartupTypeName; AdditionalAssemblyDirectories = other.AdditionalAssemblyDirectories; }
public OrleansTaskScheduler(GlobalConfiguration globalConfig, NodeConfiguration config) : this(config.MaxActiveThreads, config.DelayWarningThreshold, config.ActivationSchedulingQuantum, config.TurnWarningLengthThreshold, config.InjectMoreWorkerThreads) { }
public static void Init(ClusterConfiguration config, NodeConfiguration nodeConfig) { // Consider adding a config parameter for this maxRequestProcessingTime = config.Globals.ResponseTimeout.Multiply(5); nodeConfiguration = nodeConfig; }
/// <summary> /// Obtains the configuration for a given silo. /// </summary> /// <param name="siloName">Silo name.</param> /// <param name="siloNode">NodeConfiguration associated with the specified silo.</param> /// <returns>true if node was found</returns> public bool TryGetNodeConfigurationForSilo(string siloName, out NodeConfiguration siloNode) { return(Overrides.TryGetValue(siloName, out siloNode)); }
private SiloHandle StartOrleansSilo(Silo.SiloType type, ClusterConfiguration clusterConfig, NodeConfiguration nodeConfig) { return StartOrleansSilo(this, type, clusterConfig, nodeConfig); }
private void InitializeLogger(NodeConfiguration nodeCfg) { TraceLogger.Initialize(nodeCfg); logger = TraceLogger.GetLogger("OrleansSiloHost", TraceLogger.LoggerType.Runtime); }
/// <summary> /// Initialize log infrastrtucture for Orleans runtime sub-components /// </summary> private static void InitConsoleLogging() { Trace.Listeners.Clear(); var cfg = new NodeConfiguration {TraceFilePattern = null, TraceToConsole = false}; TraceLogger.Initialize(cfg); //TODO: Move it to use the APM APIs //var logWriter = new LogWriterToConsole(true, true); // Use compact console output & no timestamps / log message metadata //TraceLogger.LogConsumers.Add(logWriter); }
public SiloAssemblyLoader(NodeConfiguration nodeConfig) : this(nodeConfig.AdditionalAssemblyDirectories, nodeConfig.ExcludedGrainTypes) { }
public void ServerConfig_TraceFilePattern_Blank() { var cfg = new NodeConfiguration(); cfg.TraceFilePattern = string.Empty; output.WriteLine(cfg.ToString()); Assert.IsNull(cfg.TraceFileName, "TraceFileName should be null"); cfg.TraceFilePattern = null; output.WriteLine(cfg.ToString()); Assert.IsNull(cfg.TraceFileName, "TraceFileName should be null"); }
/// <summary> /// Start a new silo in the target cluster /// </summary> /// <param name="cluster">The TestCluster in which the silo should be deployed</param> /// <param name="type">The type of the silo to deploy</param> /// <param name="clusterConfig">The cluster config to use</param> /// <param name="nodeConfig">The configuration for the silo to deploy</param> /// <returns>A handle to the silo deployed</returns> public static SiloHandle StartOrleansSilo(TestCluster cluster, Silo.SiloType type, ClusterConfiguration clusterConfig, NodeConfiguration nodeConfig) { if (cluster == null) throw new ArgumentNullException(nameof(cluster)); var siloName = nodeConfig.SiloName; cluster.WriteLog("Starting a new silo in app domain {0} with config {1}", siloName, clusterConfig.ToString(siloName)); var handle = cluster.LoadSiloInNewAppDomain(siloName, type, clusterConfig, nodeConfig); return handle; }