当前位置: 首页>>代码示例>>C#>>正文


C# ClusterConfiguration.LoadFromFile方法代码示例

本文整理汇总了C#中Orleans.Runtime.Configuration.ClusterConfiguration.LoadFromFile方法的典型用法代码示例。如果您正苦于以下问题:C# ClusterConfiguration.LoadFromFile方法的具体用法?C# ClusterConfiguration.LoadFromFile怎么用?C# ClusterConfiguration.LoadFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Orleans.Runtime.Configuration.ClusterConfiguration的用法示例。


在下文中一共展示了ClusterConfiguration.LoadFromFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        protected void Init(int mode = 1)
        {
            SiloHostConfig = new TestingSiloOptions
            {
                StartPrimary = true,
                ParallelStart = false,
                PickNewDeploymentId = true,
                StartFreshOrleans = true,
                StartSecondary = false,
                SiloConfigFile = new FileInfo("OrleansConfigurationForTesting.xml"),
                LivenessType = Orleans.Runtime.Configuration.GlobalConfiguration.LivenessProviderType.MembershipTableGrain,
                StartClient = true
            };

            var clientOptions = new TestingClientOptions
            {
                ProxiedGateway = true,
                Gateways = new List<IPEndPoint>(new[]
                    {
                        new IPEndPoint(IPAddress.Loopback, TestingSiloHost.ProxyBasePort),
                    }),
                PreferedGatewayIndex = 0
            };
            ClusterConfig = new ClusterConfiguration();
            ClusterConfig.LoadFromFile(new FileInfo("OrleansConfigurationForConsulTesting.xml").FullName);
            ClusterConfig.Globals.DataConnectionString = $"host=localhost;datacenter=dc1;mode={mode}";
            ClusterConfig.Globals.DataConnectionStringForReminders = $"host=localhost;datacenter=dc1;mode={mode}";
            SiloHost = new MyTestingHost(SiloHostConfig, clientOptions);
            ConsulMembershipTable = new ConsulSystemStoreProvider();
        }
开发者ID:kowalot,项目名称:Pk.OrleansUtils,代码行数:30,代码来源:ConsulMembershipTestsBase.cs

示例2: SiloHost

 /// <summary> Constructor </summary>
 /// <param name="siloName">Name of this silo.</param>
 /// <param name="configFile">Silo config file that will be used to initialize this silo.</param>
 public SiloHost(string siloName, FileInfo configFile)
     : this(siloName)
 {
     ConfigFileName = configFile.FullName;
     var config = new ClusterConfiguration();
     config.LoadFromFile(ConfigFileName);
     SetSiloConfig(config);
 }
开发者ID:Rejendo,项目名称:orleans,代码行数:11,代码来源:SiloHost.cs

示例3: ClassInitialize

        public static void ClassInitialize(TestContext testContext)
        {
            hostName = Dns.GetHostName();
            logger = TraceLogger.GetLogger("MembershipTablePluginTests", TraceLogger.LoggerType.Application);

            ClusterConfiguration cfg = new ClusterConfiguration();
            cfg.LoadFromFile("OrleansConfigurationForTesting.xml");
            TraceLogger.Initialize(cfg.GetConfigurationForNode("Primary"));

            TraceLogger.AddTraceLevelOverride("AzureTableDataManager", Severity.Verbose3);
            TraceLogger.AddTraceLevelOverride("OrleansSiloInstanceManager", Severity.Verbose3);
            TraceLogger.AddTraceLevelOverride("Storage", Severity.Verbose3);
        }
开发者ID:danieldeb,项目名称:orleans,代码行数:13,代码来源:MembershipTablePluginTests.cs

示例4: ServerConfig_LogConsumers

        public void ServerConfig_LogConsumers()
        {
            LogManager.UnInitialize();

            string filename = "Config_LogConsumers-OrleansConfiguration.xml";

            var cfg = new ClusterConfiguration();
            cfg.LoadFromFile(filename);
            Assert.AreEqual(filename, cfg.SourceFile);

            LogManager.Initialize(cfg.CreateNodeConfigurationForSilo("Primary"));

            var actualLogConsumers = LogManager.LogConsumers.Select(x => x.GetType()).ToList();
            Xunit.Assert.Contains(typeof(DummyLogConsumer), actualLogConsumers);
            Assert.AreEqual(1, actualLogConsumers.Count);

            var actualTelemetryConsumers = LogManager.TelemetryConsumers.Select(x => x.GetType()).ToList();
            Xunit.Assert.Contains(typeof(TraceTelemetryConsumer), actualTelemetryConsumers);
            Xunit.Assert.Contains(typeof(ConsoleTelemetryConsumer), actualTelemetryConsumers);
            Assert.AreEqual(2, actualTelemetryConsumers.Count);
        }
开发者ID:caomw,项目名称:orleans,代码行数:21,代码来源:ConfigTests.cs

示例5: Limits_ServerConfig

        public void Limits_ServerConfig()
        {
            const string filename = "Config_LogConsumers-OrleansConfiguration.xml";
            var orleansConfig = new ClusterConfiguration();
            orleansConfig.LoadFromFile(filename);
            NodeConfiguration config;
            bool hasNodeConfig = orleansConfig.TryGetNodeConfigurationForSilo("Primary", out config);
            Assert.IsTrue(hasNodeConfig, "Node Primary has config");


            string limitName;
            LimitValue limit;
            //Assert.IsTrue(config.LimitManager.LimitValues.Count >= 3, "Number of LimitValues: " + string.Join(",", config.LimitValues));
            for (int i = 1; i <= 3; i++)
            {
                limitName = "Limit" + i;
                limit = config.LimitManager.GetLimit(limitName);
                Assert.IsNotNull(limit);
                Assert.AreEqual(limitName, limit.Name, "Limit name " + i);
                Assert.AreEqual(i, limit.SoftLimitThreshold, "Soft limit " + i);
                Assert.AreEqual(2 * i, limit.HardLimitThreshold, "Hard limit " + i);
            }

            limitName = "NoHardLimit";
            limit = config.LimitManager.GetLimit(limitName);
            Assert.IsNotNull(limit);
            Assert.AreEqual(limitName, limit.Name, "Limit name " + limitName);
            Assert.AreEqual(4, limit.SoftLimitThreshold, "Soft limit " + limitName);
            Assert.AreEqual(0, limit.HardLimitThreshold, "Hard limit " + limitName);
        }
开发者ID:caomw,项目名称:orleans,代码行数:30,代码来源:ConfigTests.cs

示例6: SiloConfig_SqlServer_StatsProvider

        public void SiloConfig_SqlServer_StatsProvider()
        {
            const string filename = "DevTestServerConfiguration.xml";

            var config = new ClusterConfiguration();
            config.LoadFromFile(filename);

            output.WriteLine(config);

            Assert.AreEqual(2, config.Globals.ProviderConfigurations.Count, "Number of Providers Types");
            Assert.IsTrue(config.Globals.ProviderConfigurations.Keys.Contains("Statistics"), "Stats Providers");
            ProviderCategoryConfiguration statsProviders = config.Globals.ProviderConfigurations["Statistics"];
            Assert.AreEqual(1, statsProviders.Providers.Count, "Number of Stats Providers");
            Assert.AreEqual("SQL", statsProviders.Providers.Keys.First(), "Stats provider name");
            ProviderConfiguration providerConfig = (ProviderConfiguration)statsProviders.Providers["SQL"];
            // Note: Use string here instead of typeof(SqlStatisticsPublisher).FullName to prevent cascade load of this type
            Assert.AreEqual("Orleans.Providers.SqlServer.SqlStatisticsPublisher", providerConfig.Type, "Stats provider class name");
        }
开发者ID:caomw,项目名称:orleans,代码行数:18,代码来源:ConfigTests.cs

示例7: ExtractFireAndForgetDeliveryProperty

        private bool ExtractFireAndForgetDeliveryProperty()
        {
            ClusterConfiguration orleansConfig = new ClusterConfiguration();
            orleansConfig.LoadFromFile(SiloConfigFile.FullName);
            ProviderCategoryConfiguration providerConfigs = orleansConfig.Globals.ProviderConfigurations["Stream"];
            IProviderConfiguration provider = providerConfigs.Providers[SingleStreamTestRunner.SMS_STREAM_PROVIDER_NAME];

            string fireAndForgetProperty = null;
            bool fireAndForget = false;
            if (provider.Properties.TryGetValue(SimpleMessageStreamProvider.FIRE_AND_FORGET_DELIVERY, out fireAndForgetProperty))
            {
                fireAndForget = Boolean.Parse(fireAndForgetProperty);
            }
            return fireAndForget;
        }
开发者ID:fgq841103,项目名称:orleans,代码行数:15,代码来源:SMSStreamingTests.cs

示例8: NodeLogFileName

        public void NodeLogFileName()
        {
            string siloName = "MyNode1";
            string baseLogFileName = siloName + ".log";
            string baseLogFileNamePlusOne = siloName + "-1.log";
            string expectedLogFileName = baseLogFileName;
            string configFileName = "Config_NonTimestampedLogFileNames.xml";

            if (File.Exists(baseLogFileName)) File.Delete(baseLogFileName);
            if (File.Exists(expectedLogFileName)) File.Delete(expectedLogFileName);

            var config = new ClusterConfiguration();
            config.LoadFromFile(configFileName);
            var n = config.GetConfigurationForNode(siloName);
            string fname = n.TraceFileName;
            Console.WriteLine("LogFileName = " + fname);
            
            Assert.AreEqual(baseLogFileName, fname);

            TraceLogger.Initialize(n);

            Assert.IsTrue(File.Exists(baseLogFileName), "Base name log file exists: " + baseLogFileName);
            Assert.IsTrue(File.Exists(expectedLogFileName), "Expected name log file exists: " + expectedLogFileName);
            Assert.IsFalse(File.Exists(baseLogFileNamePlusOne), "Munged log file exists: " + baseLogFileNamePlusOne);
        }
开发者ID:sbambach,项目名称:orleans,代码行数:25,代码来源:ConfigTests.cs

示例9: ServerConfig_LoadFrom

        public void ServerConfig_LoadFrom()
        {
            string filename = "Config_LogConsumers-OrleansConfiguration.xml";

            var config = new ClusterConfiguration();
            config.LoadFromFile(filename);

            Assert.IsNotNull(config.ToString(), "OrleansConfiguration.ToString");

            Assert.AreEqual(filename, Path.GetFileName(config.SourceFile), "OrleansConfiguration.SourceFile");
        }
开发者ID:caomw,项目名称:orleans,代码行数:11,代码来源:ConfigTests.cs

示例10: StartOrleansSilo

        // This is a static version that can be called without a TestingSiloHost object (host = null)
        public static SiloHandle StartOrleansSilo(TestingSiloHost host, Silo.SiloType type, TestingSiloOptions options, int instanceCount, AppDomain shared = null)
        {
            // Load initial config settings, then apply some overrides below.
            ClusterConfiguration config = new ClusterConfiguration();
            if (options.SiloConfigFile == null)
            {
                config.StandardLoad();
            }
            else
            {
                config.LoadFromFile(options.SiloConfigFile.FullName);
            }

            int basePort = options.BasePort < 0 ? BasePort : options.BasePort;

            if (config.Globals.SeedNodes.Count > 0 && options.BasePort < 0)
            {
                config.PrimaryNode = config.Globals.SeedNodes[0];
            }
            else
            {
                config.PrimaryNode = new IPEndPoint(IPAddress.Loopback, basePort);
            }
            config.Globals.SeedNodes.Clear();
            config.Globals.SeedNodes.Add(config.PrimaryNode);

            if (!String.IsNullOrEmpty(DeploymentId))
            {
                config.Globals.DeploymentId = DeploymentId;
            }
            config.Defaults.PropagateActivityId = options.PropagateActivityId;
            if (options.LargeMessageWarningThreshold > 0)
            {
                config.Defaults.LargeMessageWarningThreshold = options.LargeMessageWarningThreshold;
            }

            config.Globals.LivenessType = options.LivenessType;
            config.Globals.ReminderServiceType = options.ReminderServiceType;
            if (!String.IsNullOrEmpty(options.DataConnectionString))
            {
                config.Globals.DataConnectionString = options.DataConnectionString;
            }

            _livenessStabilizationTime = GetLivenessStabilizationTime(config.Globals);

            if (host != null)
            {
                host.Globals = config.Globals;
            }

            string siloName;
            switch (type)
            {
                case Silo.SiloType.Primary:
                    siloName = "Primary";
                    break;
                default:
                    siloName = "Secondary_" + instanceCount.ToString(CultureInfo.InvariantCulture);
                    break;
            }

            NodeConfiguration nodeConfig = config.GetConfigurationForNode(siloName);
            nodeConfig.HostNameOrIPAddress = "loopback";
            nodeConfig.Port = basePort + instanceCount;
            nodeConfig.DefaultTraceLevel = config.Defaults.DefaultTraceLevel;
            nodeConfig.PropagateActivityId = config.Defaults.PropagateActivityId;
            nodeConfig.BulkMessageLimit = config.Defaults.BulkMessageLimit;

            if (nodeConfig.ProxyGatewayEndpoint != null && nodeConfig.ProxyGatewayEndpoint.Address != null)
            {
                int proxyBasePort = options.ProxyBasePort < 0 ? ProxyBasePort : options.ProxyBasePort;
                nodeConfig.ProxyGatewayEndpoint = new IPEndPoint(nodeConfig.ProxyGatewayEndpoint.Address, proxyBasePort + instanceCount);
            }

            config.Globals.ExpectedClusterSize = 2;

            config.Overrides[siloName] = nodeConfig;

            AdjustForTest(config, options);

            WriteLog("Starting a new silo in app domain {0} with config {1}", siloName, config.ToString(siloName));
            AppDomain appDomain;
            Silo silo = LoadSiloInNewAppDomain(siloName, type, config, out appDomain);

            silo.Start();

            SiloHandle retValue = new SiloHandle
            {
                Name = siloName,
                Silo = silo,
                Options = options,
                Endpoint = silo.SiloAddress.Endpoint,
                AppDomain = appDomain,
            };
            ImportGeneratedAssemblies(retValue);
            return retValue;
        }
开发者ID:bestwpw,项目名称:orleans,代码行数:98,代码来源:TestingSiloHost.cs

示例11: Config_StorageProvider_Azure2

        public void Config_StorageProvider_Azure2()
        {
            const string filename = "Config_StorageProvider_Azure2.xml";
            const int numProviders = 2;
            var orleansConfig = new ClusterConfiguration();
            orleansConfig.LoadFromFile(filename);
            var providerConfigs = orleansConfig.Globals.ProviderConfigurations["Storage"];
            Assert.IsNotNull(providerConfigs, "Null provider configs");
            Assert.IsNotNull(providerConfigs.Providers, "Null providers");
            Assert.AreEqual(numProviders, providerConfigs.Providers.Count, "Num provider configs");

            ProviderConfiguration pCfg = (ProviderConfiguration)providerConfigs.Providers.Values.ToList()[0];
            Assert.AreEqual("orleanstest1", pCfg.Name, "Provider name #1");
            Assert.AreEqual("AzureTable", pCfg.Type, "Provider type #1");

            pCfg = (ProviderConfiguration)providerConfigs.Providers.Values.ToList()[1];
            Assert.AreEqual("orleanstest2", pCfg.Name, "Provider name #2");
            Assert.AreEqual("AzureTable", pCfg.Type, "Provider type #2");
        }
开发者ID:caomw,项目名称:orleans,代码行数:19,代码来源:ConfigTests.cs

示例12: ServerConfig_FromFile_FileNotFound

        public void ServerConfig_FromFile_FileNotFound()
        {
            const string filename = "SiloConfig_NotFound.xml";

            try
            {
                var config = new ClusterConfiguration();
                config.LoadFromFile(filename);
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten().GetBaseException();
            }

            Assert.Fail("Should have got FileNotFoundException");
        }
开发者ID:cuteant,项目名称:orleans,代码行数:16,代码来源:ConfigTests.cs

示例13: StartOrleansSilo

        /// <summary>
        /// Start a new silo in the target cluster
        /// </summary>
        /// <param name="host">The target cluster</param>
        /// <param name="type">The type of the silo to deploy</param>
        /// <param name="options">The options to use for the silo</param>
        /// <param name="instanceCount">The instance count of the silo</param>
        /// <param name="shared">The shared AppDomain to use</param>
        /// <returns>A handle to the deployed silo</returns>
        public static SiloHandle StartOrleansSilo(TestingSiloHost host, Silo.SiloType type, TestingSiloOptions options, int instanceCount, AppDomain shared = null)
        {
            if (host == null) throw new ArgumentNullException("host");

            // Load initial config settings, then apply some overrides below.
            ClusterConfiguration config = new ClusterConfiguration();
            try
            {
                if (options.SiloConfigFile == null)
                {
                    config.StandardLoad();
                }
                else
                {
                    config.LoadFromFile(options.SiloConfigFile.FullName);
                }
            }
            catch (FileNotFoundException)
            {
                if (options.SiloConfigFile != null
                    && !string.Equals(options.SiloConfigFile.Name, TestingSiloOptions.DEFAULT_SILO_CONFIG_FILE, StringComparison.InvariantCultureIgnoreCase))
                {
                    // if the user is not using the defaults, then throw because the file was legitimally not found
                    throw;
                }

                config = ClusterConfiguration.LocalhostPrimarySilo();
                config.AddMemoryStorageProvider("Default");
                config.AddMemoryStorageProvider("MemoryStore");
            }

            int basePort = options.BasePort < 0 ? BasePort : options.BasePort;


            if (config.Globals.SeedNodes.Count > 0 && options.BasePort < 0)
            {
                config.PrimaryNode = config.Globals.SeedNodes[0];
            }
            else
            {
                config.PrimaryNode = new IPEndPoint(IPAddress.Loopback, basePort);
            }
            config.Globals.SeedNodes.Clear();
            config.Globals.SeedNodes.Add(config.PrimaryNode);

            if (!String.IsNullOrEmpty(host.DeploymentId))
            {
                config.Globals.DeploymentId = host.DeploymentId;
            }

            config.Defaults.PropagateActivityId = options.PropagateActivityId;
            if (options.LargeMessageWarningThreshold > 0)
            {
                config.Defaults.LargeMessageWarningThreshold = options.LargeMessageWarningThreshold;
            }

            config.Globals.LivenessType = options.LivenessType;
            config.Globals.ReminderServiceType = options.ReminderServiceType;
            if (!String.IsNullOrEmpty(options.DataConnectionString))
            {
                config.Globals.DataConnectionString = options.DataConnectionString;
            }

            host.Globals = config.Globals;

            string siloName;
            switch (type)
            {
                case Silo.SiloType.Primary:
                    siloName = "Primary";
                    break;
                default:
                    siloName = "Secondary_" + instanceCount.ToString(CultureInfo.InvariantCulture);
                    break;
            }

            NodeConfiguration nodeConfig = config.GetOrCreateNodeConfigurationForSilo(siloName);
            nodeConfig.HostNameOrIPAddress = "loopback";
            nodeConfig.Port = basePort + instanceCount;
            nodeConfig.DefaultTraceLevel = config.Defaults.DefaultTraceLevel;
            nodeConfig.PropagateActivityId = config.Defaults.PropagateActivityId;
            nodeConfig.BulkMessageLimit = config.Defaults.BulkMessageLimit;

            int? gatewayport = null;
            if (nodeConfig.ProxyGatewayEndpoint != null && nodeConfig.ProxyGatewayEndpoint.Address != null)
            {
                gatewayport = (options.ProxyBasePort < 0 ? ProxyBasePort : options.ProxyBasePort) + instanceCount;
                nodeConfig.ProxyGatewayEndpoint = new IPEndPoint(nodeConfig.ProxyGatewayEndpoint.Address, gatewayport.Value);
            }

            config.Globals.ExpectedClusterSize = 2;
//.........这里部分代码省略.........
开发者ID:vobradovich,项目名称:orleans,代码行数:101,代码来源:TestingSiloHost.cs

示例14: ServerConfig_LogConsumers

        public void ServerConfig_LogConsumers()
        {
            TraceLogger.UnInitialize();

            string filename = "Config_LogConsumers-OrleansConfiguration.xml";


            var cfg = new ClusterConfiguration();
            cfg.LoadFromFile(filename);
            Assert.AreEqual(filename, cfg.SourceFile);

            TraceLogger.Initialize(cfg.CreateNodeConfigurationForSilo("Primary"));
            Assert.AreEqual(1, TraceLogger.LogConsumers.Count, "Number of log consumers: " + string.Join(",", TraceLogger.LogConsumers));
            Assert.AreEqual("UnitTests.DummyLogConsumer", TraceLogger.LogConsumers.Last().GetType().FullName, "Log consumer type");

            Assert.AreEqual(2, TraceLogger.TelemetryConsumers.Count,
                "Number of telemetry consumers: " + string.Join(",", TraceLogger.TelemetryConsumers));
            Assert.AreEqual(typeof(TraceTelemetryConsumer).FullName, TraceLogger.TelemetryConsumers.First().GetType().FullName, "TelemetryConsumers consumer type #1");
            Assert.AreEqual(typeof(ConsoleTelemetryConsumer).FullName, TraceLogger.TelemetryConsumers.Last().GetType().FullName, "TelemetryConsumers consumer type #1");
        }
开发者ID:cuteant,项目名称:orleans,代码行数:20,代码来源:ConfigTests.cs

示例15: GetDefaultPeriod

        public static TimeSpan GetDefaultPeriod(Logger log)
        {
            int period = 10; // Seconds

            ClusterConfiguration config = new ClusterConfiguration();
            config.LoadFromFile("ClientConfigurationForTesting.xml");
            if (config.Globals.UseAzureSystemStore)
            {
                period = 12; // azure operations take more time ... so we use a larger period
            }
            else if (config.Globals.UseSqlSystemStore)
            {
                period = 12; // SQL operations are quite fast ... so we use a shorter period
            }
            var reminderPeriod = TimeSpan.FromSeconds(period);
            log.Info("Using reminder period of {0} for ReminderServiceType={1} in ReminderTestGrain", reminderPeriod, config.Globals.ReminderServiceType);
            return reminderPeriod;
        }
开发者ID:Rejendo,项目名称:orleans,代码行数:18,代码来源:ReminderTestGrain2.cs


注:本文中的Orleans.Runtime.Configuration.ClusterConfiguration.LoadFromFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。