Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More options formatting, and related cleanup #3947

Merged
merged 2 commits into from Feb 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/Orleans.Core.Legacy/Configuration/GlobalConfiguration.cs
Expand Up @@ -565,8 +565,6 @@ public bool UseAzureSystemStore
private const int DEFAULT_GLOBAL_SINGLE_INSTANCE_NUMBER_RETRIES = 10;
private const int DEFAULT_LIVENESS_EXPECTED_CLUSTER_SIZE = 20;
public static bool ENFORCE_MINIMUM_REQUIREMENT_FOR_AGE_LIMIT = true;
public const bool DEFAULT_PERFORM_DEADLOCK_DETECTION = false;
public const bool DEFAULT_ALLOW_CALL_CHAIN_REENTRANCY = false;
public static readonly string DEFAULT_MULTICLUSTER_REGISTRATION_STRATEGY = typeof(GlobalSingleInstanceRegistration).Name;

private string dataConnectionStringForReminders;
Expand Down Expand Up @@ -615,8 +613,8 @@ public GlobalConfiguration()
this.DirectoryLazyDeregistrationDelay = GrainDirectoryOptions.DEFAULT_UNREGISTER_RACE_DELAY;
this.ClientRegistrationRefresh = SiloMessagingOptions.DEFAULT_CLIENT_REGISTRATION_REFRESH;

this.PerformDeadlockDetection = DEFAULT_PERFORM_DEADLOCK_DETECTION;
this.AllowCallChainReentrancy = DEFAULT_ALLOW_CALL_CHAIN_REENTRANCY;
this.PerformDeadlockDetection = SchedulingOptions.DEFAULT_PERFORM_DEADLOCK_DETECTION;
this.AllowCallChainReentrancy = SchedulingOptions.DEFAULT_ALLOW_CALL_CHAIN_REENTRANCY;
this.reminderServiceType = ReminderServiceProviderType.NotSpecified;
this.DefaultPlacementStrategy = GrainPlacementOptions.DEFAULT_PLACEMENT_STRATEGY;
this.DeploymentLoadPublisherRefreshTime = SiloStatisticsOptions.DEFAULT_DEPLOYMENT_LOAD_PUBLISHER_REFRESH_TIME;
Expand Down
2 changes: 1 addition & 1 deletion src/Orleans.Core.Legacy/Configuration/NodeConfiguration.cs
Expand Up @@ -207,7 +207,7 @@ public NodeConfiguration()
this.MaxActiveThreads = SchedulingOptions.DEFAULT_MAX_ACTIVE_THREADS;
this.DelayWarningThreshold = SchedulingOptions.DEFAULT_DELAY_WARNING_THRESHOLD;
this.ActivationSchedulingQuantum = SchedulingOptions.DEFAULT_ACTIVATION_SCHEDULING_QUANTUM;
this.TurnWarningLengthThreshold = SchedulingOptions.DEFAULT_DELAY_WARNING_THRESHOLD;
this.TurnWarningLengthThreshold = SchedulingOptions.DEFAULT_TURN_WARNING_THRESHOLD;
this.EnableWorkerThreadInjection = SchedulingOptions.DEFAULT_ENABLE_WORKER_THREAD_INJECTION;

this.LoadSheddingEnabled = false;
Expand Down
18 changes: 6 additions & 12 deletions src/Orleans.Core/Configuration/Options/ClientMessagingOptions.cs
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Options;

Expand All @@ -19,32 +18,27 @@ public class ClientMessagingOptions : MessagingOptions
public int ClientSenderBuckets { get; set; } = 8192;
}

public class ClientMessagingOptionFormatter : IOptionFormatter<ClientMessagingOptions>
public class ClientMessagingOptionFormatter : MessagingOptionsFormatter, IOptionFormatter<ClientMessagingOptions>
{
public string Category { get; }

public string Name => nameof(ClientMessagingOptions);

private ClientMessagingOptions options;
public ClientMessagingOptionFormatter(IOptions<ClientMessagingOptions> messageOptions)
: base(messageOptions.Value)
{
options = messageOptions.Value;
}

public IEnumerable<string> Format()
{
return new List<string>()
List<string> format = base.FormatSharedOptions();
format.AddRange(new List<string>
{
OptionFormattingUtilities.Format(nameof(options.ClientSenderBuckets), options.ClientSenderBuckets),

OptionFormattingUtilities.Format(nameof(options.ResponseTimeout), options.ResponseTimeout),
OptionFormattingUtilities.Format(nameof(options.MaxResendCount), options.MaxResendCount),
OptionFormattingUtilities.Format(nameof(options.ResendOnTimeout), options.ResendOnTimeout),
OptionFormattingUtilities.Format(nameof(options.DropExpiredMessages), options.DropExpiredMessages),
OptionFormattingUtilities.Format(nameof(options.BufferPoolBufferSize), options.BufferPoolBufferSize),
OptionFormattingUtilities.Format(nameof(options.BufferPoolMaxSize), options.BufferPoolMaxSize),
OptionFormattingUtilities.Format(nameof(options.BufferPoolPreallocationSize), options.BufferPoolPreallocationSize)
};
});
return format;
}
}
}
Expand Up @@ -24,7 +24,7 @@ public ClientStatisticsOptionsFormatter(IOptions<ClientStatisticsOptions> option

public IEnumerable<string> Format()
{
return base.FormatStatisticsOptions();
return base.FormatSharedOptions();
}
}

Expand Down
28 changes: 28 additions & 0 deletions src/Orleans.Core/Configuration/Options/GrainDirectoryOptions.cs
@@ -1,5 +1,7 @@

using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;

namespace Orleans.Hosting
{
Expand Down Expand Up @@ -62,4 +64,30 @@ public enum CachingStrategyType
public TimeSpan LazyDeregistrationDelay { get; set; } = DEFAULT_UNREGISTER_RACE_DELAY;
public static readonly TimeSpan DEFAULT_UNREGISTER_RACE_DELAY = TimeSpan.FromMinutes(1);
}

public class GrainDirectoryOptionsFormatter : IOptionFormatter<GrainDirectoryOptions>
{
public string Category { get; }

public string Name => nameof(GrainDirectoryOptions);

private GrainDirectoryOptions options;
public GrainDirectoryOptionsFormatter(IOptions<GrainDirectoryOptions> options)
{
this.options = options.Value;
}

public IEnumerable<string> Format()
{
return new List<string>()
{
OptionFormattingUtilities.Format(nameof(options.CachingStrategy),options.CachingStrategy),
OptionFormattingUtilities.Format(nameof(options.CacheSize),options.CacheSize),
OptionFormattingUtilities.Format(nameof(options.InitialCacheTTL),options.InitialCacheTTL),
OptionFormattingUtilities.Format(nameof(options.MaximumCacheTTL),options.MaximumCacheTTL),
OptionFormattingUtilities.Format(nameof(options.CacheTTLExtensionFactor),options.CacheTTLExtensionFactor),
OptionFormattingUtilities.Format(nameof(options.LazyDeregistrationDelay),options.LazyDeregistrationDelay),
};
}
}
}
24 changes: 24 additions & 0 deletions src/Orleans.Core/Configuration/Options/GrainPlacementOptions.cs
@@ -1,4 +1,6 @@
using Microsoft.Extensions.Options;
using Orleans.Runtime;
using System.Collections.Generic;

namespace Orleans.Hosting
{
Expand All @@ -10,4 +12,26 @@ public class GrainPlacementOptions
public int ActivationCountPlacementChooseOutOf { get; set; } = DEFAULT_ACTIVATION_COUNT_PLACEMENT_CHOOSE_OUT_OF;
public const int DEFAULT_ACTIVATION_COUNT_PLACEMENT_CHOOSE_OUT_OF = 2;
}

public class GrainPlacementOptionsFormatter : IOptionFormatter<GrainPlacementOptions>
{
public string Category { get; }

public string Name => nameof(GrainPlacementOptions);

private GrainPlacementOptions options;
public GrainPlacementOptionsFormatter(IOptions<GrainPlacementOptions> options)
{
this.options = options.Value;
}

public IEnumerable<string> Format()
{
return new List<string>()
{
OptionFormattingUtilities.Format(nameof(options.DefaultPlacementStrategy),options.DefaultPlacementStrategy),
OptionFormattingUtilities.Format(nameof(options.ActivationCountPlacementChooseOutOf), options.ActivationCountPlacementChooseOutOf),
};
}
}
}
27 changes: 26 additions & 1 deletion src/Orleans.Core/Configuration/Options/MessagingOptions.cs
@@ -1,7 +1,6 @@
using Orleans.Runtime;
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Options;

namespace Orleans.Hosting
{
Expand Down Expand Up @@ -54,4 +53,30 @@ public abstract class MessagingOptions
public bool PropagateActivityId { get; set; } = DEFAULT_PROPAGATE_ACTIVITY_ID;
public const bool DEFAULT_PROPAGATE_ACTIVITY_ID = Constants.DEFAULT_PROPAGATE_E2E_ACTIVITY_ID;
}

public abstract class MessagingOptionsFormatter
{
private MessagingOptions options;

protected MessagingOptionsFormatter(MessagingOptions options)
{
this.options = options;
}

protected List<string> FormatSharedOptions()
{
return new List<string>()
{
OptionFormattingUtilities.Format(nameof(this.options.ResponseTimeout), this.options.ResponseTimeout),
OptionFormattingUtilities.Format(nameof(this.options.MaxResendCount), this.options.MaxResendCount),
OptionFormattingUtilities.Format(nameof(this.options.ResendOnTimeout), this.options.ResendOnTimeout),
OptionFormattingUtilities.Format(nameof(this.options.DropExpiredMessages), this.options.DropExpiredMessages),
OptionFormattingUtilities.Format(nameof(this.options.BufferPoolBufferSize), this.options.BufferPoolBufferSize),
OptionFormattingUtilities.Format(nameof(this.options.BufferPoolMaxSize), this.options.BufferPoolMaxSize),
OptionFormattingUtilities.Format(nameof(this.options.BufferPoolPreallocationSize), this.options.BufferPoolPreallocationSize),
OptionFormattingUtilities.Format(nameof(this.options.PropagateActivityId), this.options.PropagateActivityId),
};
}
}

}
36 changes: 34 additions & 2 deletions src/Orleans.Core/Configuration/Options/SchedulingOptions.cs
@@ -1,4 +1,6 @@
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;

namespace Orleans.Hosting
{
Expand All @@ -10,12 +12,14 @@ public class SchedulingOptions
/// <summary>
/// Whether or not to perform deadlock detection.
/// </summary>
public bool PerformDeadlockDetection { get; set; }
public bool PerformDeadlockDetection { get; set; } = DEFAULT_PERFORM_DEADLOCK_DETECTION;
public const bool DEFAULT_PERFORM_DEADLOCK_DETECTION = false;

/// <summary>
/// Whether or not to allow reentrancy for calls within the same call chain.
/// </summary>
public bool AllowCallChainReentrancy { get; set; }
public bool AllowCallChainReentrancy { get; set; } = DEFAULT_ALLOW_CALL_CHAIN_REENTRANCY;
public const bool DEFAULT_ALLOW_CALL_CHAIN_REENTRANCY = false;

/// <summary>
/// The MaxActiveThreads attribute specifies the maximum number of simultaneous active threads the scheduler will allow.
Expand Down Expand Up @@ -57,4 +61,32 @@ public class SchedulingOptions
public bool EnableWorkerThreadInjection { get; set; } = DEFAULT_ENABLE_WORKER_THREAD_INJECTION;
public const bool DEFAULT_ENABLE_WORKER_THREAD_INJECTION = false;
}

public class SchedulingOptionsFormatter : IOptionFormatter<SchedulingOptions>
{
public string Category { get; }

public string Name => nameof(SchedulingOptions);

private SchedulingOptions options;
public SchedulingOptionsFormatter(IOptions<SchedulingOptions> options)
{
this.options = options.Value;
}

public IEnumerable<string> Format()
{
return new List<string>()
{
OptionFormattingUtilities.Format(nameof(options.PerformDeadlockDetection),options.PerformDeadlockDetection),
OptionFormattingUtilities.Format(nameof(options.AllowCallChainReentrancy), options.AllowCallChainReentrancy),
OptionFormattingUtilities.Format(nameof(options.DelayWarningThreshold), options.DelayWarningThreshold),
OptionFormattingUtilities.Format(nameof(options.ActivationSchedulingQuantum), options.ActivationSchedulingQuantum),
OptionFormattingUtilities.Format(nameof(options.TurnWarningLengthThreshold), options.TurnWarningLengthThreshold),
OptionFormattingUtilities.Format(nameof(options.MaxPendingWorkItemsSoftLimit), options.MaxPendingWorkItemsSoftLimit),
OptionFormattingUtilities.Format(nameof(options.MaxPendingWorkItemsHardLimit), options.MaxPendingWorkItemsHardLimit),
OptionFormattingUtilities.Format(nameof(options.EnableWorkerThreadInjection), options.EnableWorkerThreadInjection),
};
}
}
}
27 changes: 14 additions & 13 deletions src/Orleans.Core/Configuration/Options/SiloMessagingOptions.cs
Expand Up @@ -63,36 +63,37 @@ public class SiloMessagingOptions : MessagingOptions
public bool AssumeHomogenousSilosForTesting { get; set; } = false;
}

public class SiloMessageingOptionFormatter : IOptionFormatter<SiloMessagingOptions>
public class SiloMessagingOptionFormatter : MessagingOptionsFormatter, IOptionFormatter<SiloMessagingOptions>
{
public string Category { get; }

public string Name => nameof(SiloMessagingOptions);

private SiloMessagingOptions options;
public SiloMessageingOptionFormatter(IOptions<SiloMessagingOptions> messageOptions)
public SiloMessagingOptionFormatter(IOptions<SiloMessagingOptions> messageOptions)
: base(messageOptions.Value)
{
options = messageOptions.Value;
}

public IEnumerable<string> Format()
{
return new List<string>()
List<string> format = base.FormatSharedOptions();
format.AddRange(new List<string>
{
OptionFormattingUtilities.Format(nameof(options.SiloSenderQueues), options.SiloSenderQueues),
OptionFormattingUtilities.Format(nameof(options.GatewaySenderQueues), options.GatewaySenderQueues),
OptionFormattingUtilities.Format(nameof(options.MaxForwardCount), options.MaxForwardCount),
OptionFormattingUtilities.Format(nameof(options.ClientDropTimeout), options.ClientDropTimeout),

OptionFormattingUtilities.Format(nameof(options.ResponseTimeout), options.ResponseTimeout),
OptionFormattingUtilities.Format(nameof(options.MaxResendCount), options.MaxResendCount),
OptionFormattingUtilities.Format(nameof(options.ResendOnTimeout), options.ResendOnTimeout),
OptionFormattingUtilities.Format(nameof(options.DropExpiredMessages), options.DropExpiredMessages),
OptionFormattingUtilities.Format(nameof(options.BufferPoolBufferSize), options.BufferPoolBufferSize),
OptionFormattingUtilities.Format(nameof(options.BufferPoolMaxSize), options.BufferPoolMaxSize),
OptionFormattingUtilities.Format(nameof(options.BufferPoolPreallocationSize), options.BufferPoolPreallocationSize)
};
OptionFormattingUtilities.Format(nameof(options.ClientRegistrationRefresh), options.ClientRegistrationRefresh),
OptionFormattingUtilities.Format(nameof(options.MaxEnqueuedRequestsSoftLimit), options.MaxEnqueuedRequestsSoftLimit),
OptionFormattingUtilities.Format(nameof(options.MaxEnqueuedRequestsHardLimit), options.MaxEnqueuedRequestsHardLimit),
OptionFormattingUtilities.Format(nameof(options.MaxEnqueuedRequestsSoftLimit_StatelessWorker), options.MaxEnqueuedRequestsSoftLimit_StatelessWorker),
OptionFormattingUtilities.Format(nameof(options.MaxEnqueuedRequestsHardLimit_StatelessWorker), options.MaxEnqueuedRequestsHardLimit_StatelessWorker),
OptionFormattingUtilities.Format(nameof(options.MaxRequestProcessingTime), options.MaxRequestProcessingTime),
OptionFormattingUtilities.Format(nameof(options.AssumeHomogenousSilosForTesting), options.AssumeHomogenousSilosForTesting)
});
return format;
}
}

}
Expand Up @@ -50,7 +50,7 @@ public SiloStatisticsOptionsFormatter(IOptions<SiloStatisticsOptions> options)

public IEnumerable<string> Format()
{
List<string> format = base.FormatStatisticsOptions();
List<string> format = base.FormatSharedOptions();
format.AddRange(new List<string>
{
OptionFormattingUtilities.Format(nameof(this.options.DeploymentLoadPublisherRefreshTime), this.options.DeploymentLoadPublisherRefreshTime),
Expand Down
Expand Up @@ -55,7 +55,7 @@ protected StatisticsOptionsFormatter(StatisticsOptions options)
this.options = options;
}

protected List<string> FormatStatisticsOptions()
protected List<string> FormatSharedOptions()
{
return new List<string>()
{
Expand Down
24 changes: 24 additions & 0 deletions src/Orleans.Core/Configuration/Options/ThreadPoolOptions.cs
@@ -1,9 +1,33 @@

using Microsoft.Extensions.Options;
using System.Collections.Generic;

namespace Orleans.Hosting
{
public class ThreadPoolOptions
{
public int MinDotNetThreadPoolSize { get; set; } = DEFAULT_MIN_DOT_NET_THREAD_POOL_SIZE;
public const int DEFAULT_MIN_DOT_NET_THREAD_POOL_SIZE = 200;
}

public class ThreadPoolOptionsFormatter : IOptionFormatter<ThreadPoolOptions>
{
public string Category { get; }

public string Name => nameof(ThreadPoolOptions);

private ThreadPoolOptions options;
public ThreadPoolOptionsFormatter(IOptions<ThreadPoolOptions> options)
{
this.options = options.Value;
}

public IEnumerable<string> Format()
{
return new List<string>()
{
OptionFormattingUtilities.Format(nameof(options.MinDotNetThreadPoolSize),options.MinDotNetThreadPoolSize),
};
}
}
}
22 changes: 22 additions & 0 deletions src/Orleans.Core/Configuration/Options/TypeManagementOptions.cs
@@ -1,4 +1,6 @@
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;

namespace Orleans.Hosting
{
Expand All @@ -9,6 +11,26 @@ public class TypeManagementOptions
/// </summary>
public TimeSpan TypeMapRefreshInterval { get; set; } = DEFAULT_REFRESH_CLUSTER_INTERFACEMAP_TIME;
public static readonly TimeSpan DEFAULT_REFRESH_CLUSTER_INTERFACEMAP_TIME = TimeSpan.FromMinutes(1);
}

public class TypeManagementOptionsFormatter : IOptionFormatter<TypeManagementOptions>
{
public string Category { get; }

public string Name => nameof(TypeManagementOptions);

private TypeManagementOptions options;
public TypeManagementOptionsFormatter(IOptions<TypeManagementOptions> options)
{
this.options = options.Value;
}

public IEnumerable<string> Format()
{
return new List<string>()
{
OptionFormattingUtilities.Format(nameof(options.TypeMapRefreshInterval),options.TypeMapRefreshInterval),
};
}
}
}