本文整理汇总了C#中Orleans.Runtime.Configuration.ClusterConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# ClusterConfiguration类的具体用法?C# ClusterConfiguration怎么用?C# ClusterConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClusterConfiguration类属于Orleans.Runtime.Configuration命名空间,在下文中一共展示了ClusterConfiguration类的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();
}
示例2: AdjustForTest
public override void AdjustForTest(ClusterConfiguration config)
{
base.AdjustForTest(config);
config.Globals.DefaultPlacementStrategy = "ActivationCountBasedPlacement";
config.Globals.NumMissedProbesLimit = 1;
config.Globals.NumVotesForDeathDeclaration = 1;
}
示例3: GetClusterConfiguration
public ClusterConfiguration GetClusterConfiguration()
{
var config = new ClusterConfiguration();
var orleansConfig = new FabricConfigProvider<OrleansConfig>("OrleansConfig").Config;
// Configure logging and metrics collection.
//config.Defaults.StartupTypeName = typeof(SiloServiceLocator).AssemblyQualifiedName;
config.Defaults.TraceFileName = null;
config.Defaults.TraceFilePattern = null;
config.Defaults.StatisticsCollectionLevel = StatisticsLevel.Info;
config.Defaults.StatisticsLogWriteInterval = TimeSpan.FromSeconds(10);
config.Defaults.TurnWarningLengthThreshold = TimeSpan.FromSeconds(15);
config.Defaults.TraceToConsole = true;
config.Defaults.DefaultTraceLevel = Severity.Info;
// Configure providers
//config.Globals.RegisterStorageProvider<AzureTableStorage>(
// "Default",
// new Dictionary<string, string>
// {
// { "DataConnectionString", "DefaultEndpointsProtocol=https;AccountName=actorchatstorage;AccountKey=1hCY/Ak2TFrqE61cMhbPU5rkv9PuDfX7QQFU4tXCSc2AO78hLdm6u3PrGrZbUzOj7OkIZ93YKbU81VSVnBMbPg==" },
// { "UseJsonFormat", true.ToString(CultureInfo.InvariantCulture) }
// });
config.Globals.DataConnectionString = orleansConfig.DataConnectionString;
config.Globals.ReminderServiceType = GlobalConfiguration.ReminderServiceProviderType.AzureTable;
config.Globals.LivenessType = GlobalConfiguration.LivenessProviderType.AzureTable;
//config.Globals.ExpectedClusterSize = nodeList.Count; // An overestimate is tolerable.
config.Globals.ResponseTimeout = TimeSpan.FromSeconds(30);
config.Defaults.PropagateActivityId = true;
return config;
}
示例4: GetClusterConfiguration
public ClusterConfiguration GetClusterConfiguration()
{
var config = new ClusterConfiguration();
// Configure logging and metrics collection.
//config.Defaults.StartupTypeName = typeof(SiloServiceLocator).AssemblyQualifiedName;
config.Defaults.TraceFileName = null;
config.Defaults.TraceFilePattern = null;
config.Defaults.StatisticsCollectionLevel = StatisticsLevel.Info;
config.Defaults.StatisticsLogWriteInterval = TimeSpan.FromDays(6);
config.Defaults.TurnWarningLengthThreshold = TimeSpan.FromSeconds(15);
config.Defaults.TraceToConsole = true;
config.Defaults.DefaultTraceLevel = Severity.Warning;
// Configure providers
/*config.Globals.RegisterStorageProvider<AzureTableStorage>(
"Default",
new Dictionary<string, string>
{
{ "DataConnectionString", "UseDevelopmentStorage=true" },
{ "UseJsonFormat", true.ToString(CultureInfo.InvariantCulture) }
});*/
config.Globals.ReminderServiceType = GlobalConfiguration.ReminderServiceProviderType.AzureTable;
config.Globals.LivenessType = GlobalConfiguration.LivenessProviderType.AzureTable;
//config.Globals.ExpectedClusterSize = nodeList.Count; // An overestimate is tolerable.
config.Globals.ResponseTimeout = TimeSpan.FromSeconds(90);
return config;
}
示例5: InsideRuntimeClient
public InsideRuntimeClient(
Dispatcher dispatcher,
Catalog catalog,
ILocalGrainDirectory directory,
ClusterConfiguration config,
IConsistentRingProvider ring,
GrainTypeManager typeManager,
TypeMetadataCache typeMetadataCache,
Func<ISiloStatusOracle> siloStatusOracle,
OrleansTaskScheduler scheduler)
{
this.dispatcher = dispatcher;
MySilo = catalog.LocalSilo;
this.directory = directory;
ConsistentRingProvider = ring;
Catalog = catalog;
disposables = new List<IDisposable>();
callbacks = new ConcurrentDictionary<CorrelationId, CallbackData>();
Config = config;
config.OnConfigChange("Globals/Message", () => ResponseTimeout = Config.Globals.ResponseTimeout);
RuntimeClient.Current = this;
this.typeManager = typeManager;
this.Scheduler = scheduler;
this.siloStatusOracle = new Lazy<ISiloStatusOracle>(siloStatusOracle);
this.ConcreteGrainFactory = new GrainFactory(this, typeMetadataCache);
RuntimeClient.Current = this;
}
示例6: AdjustConfig
private static void AdjustConfig(ClusterConfiguration config)
{
// register stream provider
config.AddMemoryStorageProvider("PubSubStore");
config.Globals.RegisterStreamProvider<TestEventHubStreamProvider>(StreamProviderName, BuildProviderSettings());
config.Globals.ClientDropTimeout = TimeSpan.FromSeconds(5);
}
示例7: ValidateConfiguration
/// <summary>
/// Async method to validate specific cluster configuration
/// </summary>
/// <param name="config"></param>
/// <returns>Task object of boolean type for this async method </returns>
public async Task<bool> ValidateConfiguration(ClusterConfiguration config)
{
if (config.Globals.LivenessType == GlobalConfiguration.LivenessProviderType.AzureTable)
{
string deploymentId = config.Globals.DeploymentId ?? serviceRuntimeWrapper.DeploymentId;
string connectionString = config.Globals.DataConnectionString ??
serviceRuntimeWrapper.GetConfigurationSettingValue(DataConnectionConfigurationSettingName);
try
{
var manager = siloInstanceManager ?? await OrleansSiloInstanceManager.GetManager(deploymentId, connectionString);
var instances = await manager.DumpSiloInstanceTable();
logger.Verbose(instances);
}
catch (Exception exc)
{
var error = String.Format("Connecting to the storage table has failed with {0}", LogFormatter.PrintException(exc));
Trace.TraceError(error);
logger.Error(ErrorCode.AzureTable_34, error, exc);
return false;
}
}
return true;
}
示例8: Create
/// <summary>
/// Create stream queue balancer by type requested
/// </summary>
/// <param name="balancerType">queue balancer type to create</param>
/// <param name="strProviderName">name of requesting stream provider</param>
/// <param name="siloStatusOracle">membership services interface.</param>
/// <param name="clusterConfiguration">cluster configuration</param>
/// <param name="runtime">stream provider runtime environment to run in</param>
/// <param name="queueMapper">queue mapper of requesting stream provider</param>
/// <param name="siloMaturityPeriod">Maturity Period of a silo for queue rebalancing purposes</param>
/// <returns>Constructed stream queue balancer</returns>
public static IStreamQueueBalancer Create(
StreamQueueBalancerType balancerType,
string strProviderName,
ISiloStatusOracle siloStatusOracle,
ClusterConfiguration clusterConfiguration,
IStreamProviderRuntime runtime,
IStreamQueueMapper queueMapper,
TimeSpan siloMaturityPeriod)
{
if (string.IsNullOrWhiteSpace(strProviderName))
{
throw new ArgumentNullException("strProviderName");
}
if (siloStatusOracle == null)
{
throw new ArgumentNullException("siloStatusOracle");
}
if (clusterConfiguration == null)
{
throw new ArgumentNullException("clusterConfiguration");
}
if (runtime == null)
{
throw new ArgumentNullException("runtime");
}
if (queueMapper == null)
{
throw new ArgumentNullException("queueMapper");
}
bool isFixed;
switch (balancerType)
{
case StreamQueueBalancerType.ConsistentRingBalancer:
{
// Consider: for now re-use the same ConsistentRingProvider with 1 equally devided range. Remove later.
IConsistentRingProviderForGrains ringProvider = runtime.GetConsistentRingProvider(0, 1);
return new ConsistentRingQueueBalancer(ringProvider, queueMapper);
}
case StreamQueueBalancerType.DynamicAzureDeploymentBalancer:
case StreamQueueBalancerType.StaticAzureDeploymentBalancer:
{
Logger logger = LogManager.GetLogger(typeof(StreamQueueBalancerFactory).Name, LoggerType.Runtime);
var wrapper = AssemblyLoader.LoadAndCreateInstance<IDeploymentConfiguration>(Constants.ORLEANS_AZURE_UTILS_DLL, logger);
isFixed = balancerType == StreamQueueBalancerType.StaticAzureDeploymentBalancer;
return new DeploymentBasedQueueBalancer(siloStatusOracle, wrapper, queueMapper, siloMaturityPeriod, isFixed);
}
case StreamQueueBalancerType.DynamicClusterConfigDeploymentBalancer:
case StreamQueueBalancerType.StaticClusterConfigDeploymentBalancer:
{
IDeploymentConfiguration deploymentConfiguration = new StaticClusterDeploymentConfiguration(clusterConfiguration);
isFixed = balancerType == StreamQueueBalancerType.StaticClusterConfigDeploymentBalancer;
return new DeploymentBasedQueueBalancer(siloStatusOracle, deploymentConfiguration, queueMapper, siloMaturityPeriod, isFixed);
}
default:
{
string error = string.Format("Unsupported balancerType for stream provider. BalancerType: {0}, StreamProvider: {1}", balancerType, strProviderName);
throw new ArgumentOutOfRangeException("balancerType", error);
}
}
}
示例9: GetClusterConfiguration
public static ClusterConfiguration GetClusterConfiguration()
{
var config = new ClusterConfiguration();
// Configure logging and metrics collection.
config.Defaults.TraceFilePattern = Path.GetTempPath() + "{0}_{1}.log";
config.Defaults.StatisticsCollectionLevel = StatisticsLevel.Info;
config.Defaults.StatisticsLogWriteInterval = TimeSpan.FromDays(6);
config.Defaults.TurnWarningLengthThreshold = TimeSpan.FromSeconds(15);
config.Defaults.TraceToConsole = true;
config.Defaults.DefaultTraceLevel = Severity.Info;
/*config.Defaults.TraceLevelOverrides.Add(Tuple.Create("Orleans", Severity.Warning));
config.Defaults.TraceLevelOverrides.Add(Tuple.Create("Runtime", Severity.Warning));
config.Defaults.TraceLevelOverrides.Add(Tuple.Create("Dispatcher", Severity.Warning));
config.Defaults.TraceLevelOverrides.Add(Tuple.Create("MembershipOracle", Severity.Warning));
config.Defaults.TraceLevelOverrides.Add(Tuple.Create("DeploymentLoadPublisher", Severity.Warning));
config.Defaults.TraceLevelOverrides.Add(Tuple.Create("ReminderService", Severity.Warning));
config.Defaults.TraceLevelOverrides.Add(Tuple.Create("SiloLogStatistics", Severity.Warning));*/
config.Defaults.TraceLevelOverrides.Add(Tuple.Create("Catalog", Severity.Warning));
config.Defaults.TraceLevelOverrides.Add(Tuple.Create("sync.SafeTimerBase", Severity.Warning));
config.Defaults.TraceLevelOverrides.Add(Tuple.Create("asynTask.SafeTimerBase", Severity.Warning));
// Configure providers
config.Globals.RegisterBootstrapProvider<RaftBootstrap>(new RaftBootstrap().Name);
config.Globals.RegisterStorageProvider<MemoryStorage>("Default");
config.Globals.ReminderServiceType = GlobalConfiguration.ReminderServiceProviderType.ReminderTableGrain;
config.Globals.LivenessType = GlobalConfiguration.LivenessProviderType.MembershipTableGrain;
// Configure clustering.
config.Globals.DeploymentId = "test";
//config.Globals.ExpectedClusterSize = nodeList.Count; // An overestimate is tolerable.
config.Globals.ResponseTimeout = TimeSpan.FromSeconds(90);
return config;
}
示例10: 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);
}
示例11: StaticClusterDeploymentConfiguration
public StaticClusterDeploymentConfiguration(ClusterConfiguration clusterConfiguration)
{
if (clusterConfiguration == null)
{
throw new ArgumentNullException("clusterConfiguration");
}
_clusterConfiguration = clusterConfiguration;
}
示例12: ClientObserverRegistrar
internal ClientObserverRegistrar(SiloAddress myAddr, ILocalGrainDirectory dir, OrleansTaskScheduler scheduler, ClusterConfiguration config)
: base(Constants.ClientObserverRegistrarId, myAddr)
{
grainDirectory = dir;
myAddress = myAddr;
this.scheduler = scheduler;
orleansConfig = config;
logger = LogManager.GetLogger(typeof(ClientObserverRegistrar).Name);
}
示例13: GetClusterConfiguration
public ClusterConfiguration GetClusterConfiguration()
{
var config = new ClusterConfiguration();
config.Globals.DeploymentId = Regex.Replace(this.Context.ServiceName.PathAndQuery.Trim('/'), "[^a-zA-Z0-9_]", "_");
config.Globals.ReminderServiceType = GlobalConfiguration.ReminderServiceProviderType.ReminderTableGrain;
config.Globals.LivenessType = GlobalConfiguration.LivenessProviderType.AzureTable;
config.Globals.DataConnectionString = "UseDevelopmentStorage=true";
return config;
}
示例14: Create
/// <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;
}
示例15: TestInitialize
public void TestInitialize()
{
MessagingStatisticsGroup.Init(false);
var orleansConfig = new ClusterConfiguration();
orleansConfig.StandardLoad();
BufferPool.InitGlobalBufferPool(orleansConfig.Globals);
SerializationManager.InitializeForTesting();
}