本文整理汇总了C#中Orleans.Runtime.Configuration.ClusterConfiguration.GetOrAddConfigurationForNode方法的典型用法代码示例。如果您正苦于以下问题:C# ClusterConfiguration.GetOrAddConfigurationForNode方法的具体用法?C# ClusterConfiguration.GetOrAddConfigurationForNode怎么用?C# ClusterConfiguration.GetOrAddConfigurationForNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orleans.Runtime.Configuration.ClusterConfiguration
的用法示例。
在下文中一共展示了ClusterConfiguration.GetOrAddConfigurationForNode方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AdjustClusterConfiguration
public static void AdjustClusterConfiguration(ClusterConfiguration config)
{
var settings = new Dictionary<string, string>();
// get initial settings from configs
ProviderConfig.WriteProperties(settings);
EventHubConfig.WriteProperties(settings);
// add queue balancer setting
settings.Add(PersistentStreamProviderConfig.QUEUE_BALANCER_TYPE, StreamQueueBalancerType.DynamicClusterConfigDeploymentBalancer.ToString());
// register stream provider
config.Globals.RegisterStreamProvider<EventHubStreamProvider>(StreamProviderName, settings);
config.Globals.RegisterStorageProvider<MemoryStorage>("PubSubStore");
// make sure all node configs exist, for dynamic cluster queue balancer
config.GetOrAddConfigurationForNode("Primary");
config.GetOrAddConfigurationForNode("Secondary_1");
}
示例2: 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.GetOrAddConfigurationForNode("Primary"));
TraceLogger.AddTraceLevelOverride("AzureTableDataManager", Severity.Verbose3);
TraceLogger.AddTraceLevelOverride("OrleansSiloInstanceManager", Severity.Verbose3);
TraceLogger.AddTraceLevelOverride("Storage", Severity.Verbose3);
}
示例3: SetSiloConfig
/// <summary>
/// Allows silo config to be programmatically set.
/// </summary>
/// <param name="config">Configuration data for this silo & cluster.</param>
private void SetSiloConfig(ClusterConfiguration config)
{
Config = config;
if (Verbose > 0)
Config.Defaults.DefaultTraceLevel = (Severity.Verbose - 1 + Verbose);
if (!String.IsNullOrEmpty(DeploymentId))
Config.Globals.DeploymentId = DeploymentId;
if (string.IsNullOrWhiteSpace(Name))
throw new ArgumentException("SiloName not defined - cannot initialize config");
NodeConfig = Config.GetOrAddConfigurationForNode(Name);
Type = NodeConfig.IsPrimaryNode ? Silo.SiloType.Primary : Silo.SiloType.Secondary;
if (TraceFilePath != null)
{
var traceFileName = Config.GetOrAddConfigurationForNode(Name).TraceFileName;
if (traceFileName != null && !Path.IsPathRooted(traceFileName))
Config.GetOrAddConfigurationForNode(Name).TraceFileName = TraceFilePath + "\\" + traceFileName;
}
ConfigLoaded = true;
InitializeLogger(config.GetOrAddConfigurationForNode(Name));
}
示例4: StartOrleansSilo
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();
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(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.livenessStabilizationTime = GetLivenessStabilizationTime(config.Globals);
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.GetOrAddConfigurationForNode(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 = host.LoadSiloInNewAppDomain(siloName, type, config, out appDomain);
silo.Start();
SiloHandle retValue = new SiloHandle
{
Name = siloName,
Silo = silo,
Options = options,
Endpoint = silo.SiloAddress.Endpoint,
AppDomain = appDomain,
};
host.ImportGeneratedAssemblies(retValue);
return retValue;
}
示例5: InitSchedulerLogging
internal static void InitSchedulerLogging()
{
TraceLogger.UnInitialize();
//TraceLogger.LogConsumers.Add(new LogWriterToConsole());
if (!Logger.TelemetryConsumers.OfType<ConsoleTelemetryConsumer>().Any())
{
Logger.TelemetryConsumers.Add(new ConsoleTelemetryConsumer());
}
var traceLevels = new[]
{
Tuple.Create("Scheduler", Severity.Verbose3),
Tuple.Create("Scheduler.WorkerPoolThread", Severity.Verbose2),
};
TraceLogger.SetTraceLevelOverrides(new List<Tuple<string, Severity>>(traceLevels));
var orleansConfig = new ClusterConfiguration();
orleansConfig.StandardLoad();
NodeConfiguration config = orleansConfig.GetOrAddConfigurationForNode("Primary");
StatisticsCollector.Initialize(config);
SchedulerStatisticsGroup.Init();
}
示例6: Config_NewConfigTest
public void Config_NewConfigTest()
{
TextReader input = File.OpenText("Config_TestSiloConfig.xml");
ClusterConfiguration config = new ClusterConfiguration();
config.Load(input);
input.Close();
Assert.AreEqual<int>(2, config.Globals.SeedNodes.Count, "Seed node count is incorrect");
Assert.AreEqual<IPEndPoint>(new IPEndPoint(IPAddress.Loopback, 11111), config.Globals.SeedNodes[0], "First seed node is set incorrectly");
Assert.AreEqual<IPEndPoint>(new IPEndPoint(IPAddress.IPv6Loopback, 22222), config.Globals.SeedNodes[1], "Second seed node is set incorrectly");
Assert.AreEqual<int>(12345, config.Defaults.Port, "Default port is set incorrectly");
NodeConfiguration nc = config.GetOrAddConfigurationForNode("Node1");
Assert.AreEqual<int>(11111, nc.Port, "Port is set incorrectly for node Node1");
Assert.IsTrue(nc.IsPrimaryNode, "Node1 should be primary node");
Assert.IsTrue(nc.IsSeedNode, "Node1 should be seed node");
Assert.IsFalse(nc.IsGatewayNode, "Node1 should not be gateway node");
nc = config.GetOrAddConfigurationForNode("Node2");
Assert.AreEqual<int>(22222, nc.Port, "Port is set incorrectly for node Node2");
Assert.IsFalse(nc.IsPrimaryNode, "Node2 should not be primary node");
Assert.IsTrue(nc.IsSeedNode, "Node2 should be seed node");
Assert.IsTrue(nc.IsGatewayNode, "Node2 should be gateway node");
nc = config.GetOrAddConfigurationForNode("Store");
Assert.AreEqual<int>(12345, nc.Port, "IP port is set incorrectly for node Store");
Assert.IsFalse(nc.IsPrimaryNode, "Store should not be primary node");
Assert.IsFalse(nc.IsSeedNode, "Store should not be seed node");
Assert.IsFalse(nc.IsGatewayNode, "Store should not be gateway node");
//IPAddress[] ips = Dns.GetHostAddresses("");
//IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, 12345);
//for (int i = 0; i < ips.Length; i++)
//{
// if ((ips[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) && !IPAddress.Loopback.Equals(ips[i]))
// {
// ep = new IPEndPoint(ips[i], 12345);
// break;
// }
//}
//Assert.AreEqual<IPEndPoint>(ep, nc.Endpoint, "IP endpoint is set incorrectly for node Store");
}
示例7: Limits_ServerConfig_NotSpecified
public void Limits_ServerConfig_NotSpecified()
{
const string filename = "Config_LogConsumers-OrleansConfiguration.xml";
var orleansConfig = new ClusterConfiguration();
orleansConfig.LoadFromFile(filename);
NodeConfiguration config = orleansConfig.GetOrAddConfigurationForNode("Primary");
string limitName = "NotPresent";
LimitValue limit = config.LimitManager.GetLimit(limitName);
Assert.AreEqual(0, limit.SoftLimitThreshold);
Assert.AreEqual(0, limit.HardLimitThreshold);
Assert.AreEqual(limitName, limit.Name);
}
示例8: Limits_ServerConfig_NotSpecified_WithDefault
public void Limits_ServerConfig_NotSpecified_WithDefault()
{
const string filename = "Config_LogConsumers-OrleansConfiguration.xml";
var orleansConfig = new ClusterConfiguration();
orleansConfig.LoadFromFile(filename);
NodeConfiguration config = orleansConfig.GetOrAddConfigurationForNode("Primary");
string limitName;
LimitValue limit;
for (int i = 1; i <= 3; i++)
{
limitName = "NotPresent" + i;
limit = config.LimitManager.GetLimit(limitName, i);
Assert.IsNotNull(limit);
Assert.AreEqual(limitName, limit.Name, "Limit name " + i);
Assert.AreEqual(i, limit.SoftLimitThreshold, "Soft limit " + i);
Assert.AreEqual(0, limit.HardLimitThreshold, "No Hard limit " + i);
}
for (int i = 1; i <= 3; i++)
{
limitName = "NotPresent" + i;
limit = config.LimitManager.GetLimit(limitName, i, 2 * i);
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);
}
}
示例9: Limits_ServerConfig
public void Limits_ServerConfig()
{
const string filename = "Config_LogConsumers-OrleansConfiguration.xml";
var orleansConfig = new ClusterConfiguration();
orleansConfig.LoadFromFile(filename);
NodeConfiguration config = orleansConfig.GetOrAddConfigurationForNode("Primary");
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);
}
示例10: 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.GetOrAddConfigurationForNode("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");
}
示例11: LogFile_Write_NotExists
public void LogFile_Write_NotExists()
{
const string siloName = "MyNode4";
const string configFileName = "Config_NonTimestampedLogFileNames.xml";
string logFileName = siloName + ".log";
FileInfo fileInfo = new FileInfo(logFileName);
DeleteIfExists(fileInfo);
Assert.IsFalse(File.Exists(fileInfo.FullName), "Log file should not exist: " + fileInfo.FullName);
long initialSize = 0;
var config = new ClusterConfiguration();
config.LoadFromFile(configFileName);
var n = config.GetOrAddConfigurationForNode(siloName);
string fname = n.TraceFileName;
Console.WriteLine("LogFileName = " + fname);
Assert.AreEqual(logFileName, fname);
TraceLogger.Initialize(n);
Assert.IsTrue(File.Exists(fileInfo.FullName), "Log file exists - before write: " + fileInfo.FullName);
TraceLogger myLogger = TraceLogger.GetLogger("MyLogger", TraceLogger.LoggerType.Application);
myLogger.Info("Write something");
fileInfo.Refresh(); // Need to refresh cached view of FileInfo
Assert.IsTrue(fileInfo.Exists, "Log file exists - after write: " + fileInfo.FullName);
long currentSize = fileInfo.Length;
Assert.IsTrue(currentSize > initialSize, "Log file {0} should have been written to: Initial size = {1} Current size = {2}", logFileName, initialSize, currentSize);
}
示例12: NodeLogFileNameAlreadyExists
public void NodeLogFileNameAlreadyExists()
{
string siloName = "MyNode2";
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);
if (!File.Exists(baseLogFileName)) File.Create(baseLogFileName).Close();
var config = new ClusterConfiguration();
config.LoadFromFile(configFileName);
var n = config.GetOrAddConfigurationForNode(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);
}
示例13: LogFileName
public void LogFileName()
{
var oc = new ClusterConfiguration();
oc.StandardLoad();
var n = oc.GetOrAddConfigurationForNode("Node1");
string fname = n.TraceFileName;
Console.WriteLine("LogFileName = " + fname);
Assert.IsNotNull(fname);
Assert.IsFalse(fname.Contains(":"), "Log file name should not contain colons.");
// Check that .NET is happy with the file name
var f = new FileInfo(fname);
Assert.IsNotNull(f.Name);
Assert.AreEqual(fname, f.Name);
}