|
1 | | - |
2 | | -using System; |
3 | 1 | using Orleans.Runtime.GrainDirectory; |
4 | 2 |
|
5 | | -namespace Orleans.Configuration |
| 3 | +namespace Orleans.Configuration; |
| 4 | + |
| 5 | +public class GrainDirectoryOptions |
6 | 6 | { |
7 | | - public class GrainDirectoryOptions |
| 7 | + /// <summary> |
| 8 | + /// Configuration type that controls the type of the grain directory caching algorithm that silo use. |
| 9 | + /// </summary> |
| 10 | + public enum CachingStrategyType |
8 | 11 | { |
9 | | - /// <summary> |
10 | | - /// Configuration type that controls the type of the grain directory caching algorithm that silo use. |
11 | | - /// </summary> |
12 | | - public enum CachingStrategyType |
13 | | - { |
14 | | - /// <summary>Don't cache.</summary> |
15 | | - None, |
16 | | - /// <summary>Standard fixed-size LRU.</summary> |
17 | | - LRU, |
18 | | - /// <summary>Adaptive caching with fixed maximum size and refresh. This option should be used in production.</summary> |
19 | | - [Obsolete("Adaptive caching is deprecated in favor of LRU and will be removed in a future version. This value is now an alias for LRU.")] |
20 | | - Adaptive, |
21 | | - /// <summary>Custom cache implementation, configured by registering an <see cref="IGrainDirectoryCache"/> implementation in the dependency injection container.</summary> |
22 | | - Custom |
23 | | - } |
24 | | - |
25 | | - /// <summary> |
26 | | - /// Gets or sets the caching strategy to use. |
27 | | - /// The options are None, which means don't cache directory entries locally; |
28 | | - /// LRU, which indicates that a standard fixed-size least recently used strategy should be used; and |
29 | | - /// Adaptive, which indicates that an adaptive strategy with a fixed maximum size should be used. |
30 | | - /// The LRU strategy is used by default. |
31 | | - /// </summary> |
32 | | - public CachingStrategyType CachingStrategy { get; set; } = DEFAULT_CACHING_STRATEGY; |
33 | | - |
34 | | - /// <summary> |
35 | | - /// The default value for <see cref="CachingStrategy"/>. |
36 | | - /// </summary> |
37 | | - public const CachingStrategyType DEFAULT_CACHING_STRATEGY = CachingStrategyType.LRU; |
38 | | - |
39 | | - /// <summary> |
40 | | - /// Gets or sets the maximum number of grains to cache directory information for. |
41 | | - /// </summary> |
42 | | - public int CacheSize { get; set; } = DEFAULT_CACHE_SIZE; |
43 | | - |
44 | | - /// <summary> |
45 | | - /// The default value for <see cref="CacheSize"/>. |
46 | | - /// </summary> |
47 | | - public const int DEFAULT_CACHE_SIZE = 1_000_000; |
48 | | - |
49 | | - /// <summary> |
50 | | - /// Gets or sets the initial (minimum) time, in seconds, to keep a cache entry before revalidating. |
51 | | - /// </summary> |
52 | | - [Obsolete("InitialCacheTTL is deprecated and will be removed in a future version.")] |
53 | | - public TimeSpan InitialCacheTTL { get; set; } = DEFAULT_INITIAL_CACHE_TTL; |
54 | | - |
55 | | - /// <summary> |
56 | | - /// The default value for <see cref="InitialCacheTTL"/>. |
57 | | - /// </summary> |
58 | | - [Obsolete("DEFAULT_INITIAL_CACHE_TTL is deprecated and will be removed in a future version.")] |
59 | | - public static readonly TimeSpan DEFAULT_INITIAL_CACHE_TTL = TimeSpan.FromSeconds(30); |
60 | | - |
61 | | - /// <summary> |
62 | | - /// Gets or sets the maximum time, in seconds, to keep a cache entry before revalidating. |
63 | | - /// </summary> |
64 | | - [Obsolete("MaximumCacheTTL is deprecated and will be removed in a future version.")] |
65 | | - public TimeSpan MaximumCacheTTL { get; set; } = DEFAULT_MAXIMUM_CACHE_TTL; |
66 | | - |
67 | | - /// <summary> |
68 | | - /// The default value for <see cref="MaximumCacheTTL"/>. |
69 | | - /// </summary> |
70 | | - [Obsolete("DEFAULT_MAXIMUM_CACHE_TTL is deprecated and will be removed in a future version.")] |
71 | | - public static readonly TimeSpan DEFAULT_MAXIMUM_CACHE_TTL = TimeSpan.FromSeconds(240); |
72 | | - |
73 | | - /// <summary> |
74 | | - /// Gets or sets the factor by which cache entry TTLs should be extended when they are found to be stable. |
75 | | - /// </summary> |
76 | | - [Obsolete("CacheTTLExtensionFactor is deprecated and will be removed in a future version.")] |
77 | | - public double CacheTTLExtensionFactor { get; set; } = DEFAULT_TTL_EXTENSION_FACTOR; |
78 | | - |
79 | | - /// <summary> |
80 | | - /// The default value for <see cref="CacheTTLExtensionFactor"/>. |
81 | | - /// </summary> |
82 | | - [Obsolete("DEFAULT_TTL_EXTENSION_FACTOR is deprecated and will be removed in a future version.")] |
83 | | - public const double DEFAULT_TTL_EXTENSION_FACTOR = 2.0; |
84 | | - |
85 | | - /// <summary> |
86 | | - /// Gets or sets the time span between when we have added an entry for an activation to the grain directory and when we are allowed |
87 | | - /// to conditionally remove that entry. |
88 | | - /// Conditional deregistration is used for lazy clean-up of activations whose prompt deregistration failed for some reason (e.g., message failure). |
89 | | - /// This should always be at least one minute, since we compare the times on the directory partition, so message delays and clcks skues have |
90 | | - /// to be allowed. |
91 | | - /// </summary> |
92 | | - public TimeSpan LazyDeregistrationDelay { get; set; } = DEFAULT_UNREGISTER_RACE_DELAY; |
93 | | - |
94 | | - /// <summary> |
95 | | - /// The default value for <see cref="LazyDeregistrationDelay"/>. |
96 | | - /// </summary> |
97 | | - public static readonly TimeSpan DEFAULT_UNREGISTER_RACE_DELAY = TimeSpan.FromMinutes(1); |
| 12 | + /// <summary>Don't cache.</summary> |
| 13 | + None, |
| 14 | + /// <summary>Standard fixed-size LRU.</summary> |
| 15 | + LRU, |
| 16 | + /// <summary>Adaptive caching with fixed maximum size and refresh. This option should be used in production.</summary> |
| 17 | + [Obsolete("Adaptive caching is deprecated in favor of LRU and will be removed in a future version. This value is now an alias for LRU.")] |
| 18 | + Adaptive, |
| 19 | + /// <summary>Custom cache implementation, configured by registering an <see cref="IGrainDirectoryCache"/> implementation in the dependency injection container.</summary> |
| 20 | + Custom |
98 | 21 | } |
| 22 | + |
| 23 | + /// <summary> |
| 24 | + /// Gets or sets the caching strategy to use. |
| 25 | + /// The options are None, which means don't cache directory entries locally; |
| 26 | + /// LRU, which indicates that a standard fixed-size least recently used strategy should be used; and |
| 27 | + /// Adaptive, which indicates that an adaptive strategy with a fixed maximum size should be used. |
| 28 | + /// The LRU strategy is used by default. |
| 29 | + /// </summary> |
| 30 | + public CachingStrategyType CachingStrategy { get; set; } = DEFAULT_CACHING_STRATEGY; |
| 31 | + |
| 32 | + /// <summary> |
| 33 | + /// The default value for <see cref="CachingStrategy"/>. |
| 34 | + /// </summary> |
| 35 | + public const CachingStrategyType DEFAULT_CACHING_STRATEGY = CachingStrategyType.LRU; |
| 36 | + |
| 37 | + /// <summary> |
| 38 | + /// Gets or sets the maximum number of grains to cache directory information for. |
| 39 | + /// </summary> |
| 40 | + public int CacheSize { get; set; } = DEFAULT_CACHE_SIZE; |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// The default value for <see cref="CacheSize"/>. |
| 44 | + /// </summary> |
| 45 | + public const int DEFAULT_CACHE_SIZE = 1_000_000; |
| 46 | + |
| 47 | + /// <summary> |
| 48 | + /// Gets or sets the initial (minimum) time, in seconds, to keep a cache entry before revalidating. |
| 49 | + /// </summary> |
| 50 | + [Obsolete("InitialCacheTTL is deprecated and will be removed in a future version.")] |
| 51 | + public TimeSpan InitialCacheTTL { get; set; } = DEFAULT_INITIAL_CACHE_TTL; |
| 52 | + |
| 53 | + /// <summary> |
| 54 | + /// The default value for <see cref="InitialCacheTTL"/>. |
| 55 | + /// </summary> |
| 56 | + [Obsolete("DEFAULT_INITIAL_CACHE_TTL is deprecated and will be removed in a future version.")] |
| 57 | + public static readonly TimeSpan DEFAULT_INITIAL_CACHE_TTL = TimeSpan.FromSeconds(30); |
| 58 | + |
| 59 | + /// <summary> |
| 60 | + /// Gets or sets the maximum time, in seconds, to keep a cache entry before revalidating. |
| 61 | + /// </summary> |
| 62 | + [Obsolete("MaximumCacheTTL is deprecated and will be removed in a future version.")] |
| 63 | + public TimeSpan MaximumCacheTTL { get; set; } = DEFAULT_MAXIMUM_CACHE_TTL; |
| 64 | + |
| 65 | + /// <summary> |
| 66 | + /// The default value for <see cref="MaximumCacheTTL"/>. |
| 67 | + /// </summary> |
| 68 | + [Obsolete("DEFAULT_MAXIMUM_CACHE_TTL is deprecated and will be removed in a future version.")] |
| 69 | + public static readonly TimeSpan DEFAULT_MAXIMUM_CACHE_TTL = TimeSpan.FromSeconds(240); |
| 70 | + |
| 71 | + /// <summary> |
| 72 | + /// Gets or sets the factor by which cache entry TTLs should be extended when they are found to be stable. |
| 73 | + /// </summary> |
| 74 | + [Obsolete("CacheTTLExtensionFactor is deprecated and will be removed in a future version.")] |
| 75 | + public double CacheTTLExtensionFactor { get; set; } = DEFAULT_TTL_EXTENSION_FACTOR; |
| 76 | + |
| 77 | + /// <summary> |
| 78 | + /// The default value for <see cref="CacheTTLExtensionFactor"/>. |
| 79 | + /// </summary> |
| 80 | + [Obsolete("DEFAULT_TTL_EXTENSION_FACTOR is deprecated and will be removed in a future version.")] |
| 81 | + public const double DEFAULT_TTL_EXTENSION_FACTOR = 2.0; |
| 82 | + |
| 83 | + /// <summary> |
| 84 | + /// Gets or sets the time span between when we have added an entry for an activation to the grain directory and when we are allowed |
| 85 | + /// to conditionally remove that entry. |
| 86 | + /// Conditional deregistration is used for lazy clean-up of activations whose prompt deregistration failed for some reason (e.g., message failure). |
| 87 | + /// This should always be at least one minute, since we compare the times on the directory partition, so message delays and clcks skues have |
| 88 | + /// to be allowed. |
| 89 | + /// </summary> |
| 90 | + public TimeSpan LazyDeregistrationDelay { get; set; } = DEFAULT_UNREGISTER_RACE_DELAY; |
| 91 | + |
| 92 | + /// <summary> |
| 93 | + /// The default value for <see cref="LazyDeregistrationDelay"/>. |
| 94 | + /// </summary> |
| 95 | + public static readonly TimeSpan DEFAULT_UNREGISTER_RACE_DELAY = TimeSpan.FromMinutes(1); |
| 96 | + |
| 97 | + /// <summary> |
| 98 | + /// Gets or sets the duration for the safety lease hold applied after an ungraceful silo failure. |
| 99 | + /// This duration applies in two scenarios: |
| 100 | + /// <list type="bullet"> |
| 101 | + /// <item>When a specific silo crashes ungracefully, grain lease holds prevent individual re-registration of its grains for this duration.</item> |
| 102 | + /// <item>When a directory partition can not acquire a snapshot from a previous owner, range lease holds prevent new registrations in that whole range for this duration.</item> |
| 103 | + /// </list> |
| 104 | + /// </summary> |
| 105 | + /// <remarks> |
| 106 | + /// Depending on the value of this, the duration is understood as: |
| 107 | + /// <list type="bullet"> |
| 108 | + /// <item><c>SafetyLeaseHoldDuration > TimeSpan.Zero</c> - The lease duration is explicitly controlled by the user.</item> |
| 109 | + /// <item><c>SafetyLeaseHoldDuration <= TimeSpan.Zero</c> - The system computes a lease duration as: |
| 110 | + /// <c>2 × <see cref="ClusterMembershipOptions.ProbeTimeout"/> × <see cref="ClusterMembershipOptions.NumMissedProbesLimit"/></c>.</item> |
| 111 | + /// </list> |
| 112 | + /// </remarks> |
| 113 | + public TimeSpan SafetyLeaseHoldDuration { get; set; } |
| 114 | + |
| 115 | + /// <summary> |
| 116 | + /// The default value for <see cref="SafetyLeaseHoldDuration"/> |
| 117 | + /// </summary> |
| 118 | + public static readonly TimeSpan DEFAULT_SAFETY_LEASE_HOLD_DURATION = TimeSpan.Zero; |
99 | 119 | } |
0 commit comments