本文整理汇总了C#中Orleans.Runtime.Configuration.ClusterConfiguration.GetOrCreateNodeConfigurationForSilo方法的典型用法代码示例。如果您正苦于以下问题:C# ClusterConfiguration.GetOrCreateNodeConfigurationForSilo方法的具体用法?C# ClusterConfiguration.GetOrCreateNodeConfigurationForSilo怎么用?C# ClusterConfiguration.GetOrCreateNodeConfigurationForSilo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orleans.Runtime.Configuration.ClusterConfiguration
的用法示例。
在下文中一共展示了ClusterConfiguration.GetOrCreateNodeConfigurationForSilo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNodeConfiguration
public static NodeConfiguration AddNodeConfiguration(ClusterConfiguration config, Silo.SiloType siloType, short instanceNumber, int baseSiloPort, int baseGatewayPort)
{
string siloName;
switch (siloType)
{
case Silo.SiloType.Primary:
siloName = Silo.PrimarySiloName;
break;
default:
siloName = $"Secondary_{instanceNumber}";
break;
}
NodeConfiguration nodeConfig = config.GetOrCreateNodeConfigurationForSilo(siloName);
nodeConfig.HostNameOrIPAddress = "loopback";
nodeConfig.Port = baseSiloPort + instanceNumber;
var proxyAddress = nodeConfig.ProxyGatewayEndpoint?.Address ?? config.Defaults.ProxyGatewayEndpoint?.Address;
if (proxyAddress != null)
{
nodeConfig.ProxyGatewayEndpoint = new IPEndPoint(proxyAddress, baseGatewayPort + instanceNumber);
}
config.Overrides[siloName] = nodeConfig;
return nodeConfig;
}
示例2: 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.GetOrCreateNodeConfigurationForSilo(Name);
Type = NodeConfig.IsPrimaryNode ? Silo.SiloType.Primary : Silo.SiloType.Secondary;
if (TraceFilePath != null)
{
var traceFileName = NodeConfig.TraceFileName;
if (traceFileName != null && !Path.IsPathRooted(traceFileName))
NodeConfig.TraceFileName = TraceFilePath + "\\" + traceFileName;
}
ConfigLoaded = true;
InitializeLogger(NodeConfig);
}
示例3: 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;
//.........这里部分代码省略.........
示例4: AdjustConfig
private static void AdjustConfig(ClusterConfiguration config)
{
// register stream provider
config.Globals.RegisterStreamProvider<EventHubStreamProvider>(StreamProviderName, BuildProviderSettings());
config.Globals.RegisterStorageProvider<AzureTableStorage>(
ImplicitSubscription_RecoverableStream_CollectorGrain.StorageProviderName,
new Dictionary<string, string>
{
{"DataConnectionString", StorageTestConstants.DataConnectionString}
});
// Make sure a node config exist for each silo in the cluster.
// This is required for the DynamicClusterConfigDeploymentBalancer to properly balance queues.
// GetConfigurationForNode will materialize a node in the configuration for each silo, if one does not already exist.
config.GetOrCreateNodeConfigurationForSilo("Primary");
config.GetOrCreateNodeConfigurationForSilo("Secondary_1");
}