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

Revert singleton app version #7287

Closed
Original file line number Diff line number Diff line change
Expand Up @@ -880,9 +880,7 @@ private void InitializeFSM()
{
case StartOldestChangedBuffer:
{
_oldestChangedBuffer = Context.ActorOf(
Actor.Props.Create(() => new OldestChangedBuffer(_settings.Role, _settings.ConsiderAppVersion))
.WithDispatcher(Context.Props.Dispatcher));
_oldestChangedBuffer = Context.ActorOf(Actor.Props.Create<OldestChangedBuffer>(_settings.Role).WithDispatcher(Context.Props.Dispatcher));
GetNextOldestChanged();
return Stay();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public static ClusterSingletonManagerSettings Create(Config config)
role: RoleOption(config.GetString("role")),
removalMargin: TimeSpan.Zero, // defaults to ClusterSettings.DownRemovalMargin
handOverRetryInterval: config.GetTimeSpan("hand-over-retry-interval"),
leaseSettings: lease,
considerAppVersion: config.GetBoolean("consider-app-version"));
leaseSettings: lease);
}

private static string RoleOption(string role)
Expand Down Expand Up @@ -92,14 +91,6 @@ private static string RoleOption(string role)
/// LeaseSettings for acquiring before creating the singleton actor
/// </summary>
public LeaseUsageSettings LeaseSettings { get; }


/// <summary>
/// Should <see cref="Member.AppVersion"/> be considered when the cluster singleton instance is being moved to another node.
/// When set to false, singleton instance will always be created on oldest member.
/// When set to true, singleton instance will be created on the oldest member with the highest <see cref="Member.AppVersion"/> number.
/// </summary>
public bool ConsiderAppVersion { get; }

/// <summary>
/// Creates a new instance of the <see cref="ClusterSingletonManagerSettings"/>.
Expand All @@ -123,22 +114,25 @@ private static string RoleOption(string role)
/// over has started or the previous oldest member is removed from the cluster
/// (+ <paramref name="removalMargin"/>).
/// </param>
/// <param name="leaseSettings">LeaseSettings for acquiring before creating the singleton actor</param>
/// <param name="considerAppVersion">
/// Should <see cref="Member.AppVersion"/> be considered when the cluster singleton instance is being moved to another node.
/// When set to false, singleton instance will always be created on oldest member.
/// When set to true, singleton instance will be created on the oldest member with the highest <see cref="Member.AppVersion"/> number.
/// </param>
/// <exception cref="ArgumentException">TBD</exception>
[Obsolete("considerAppVersion is not supported anymore, please use constructor that does not have the considerAppVersion argument. Since 1.5.27")]
public ClusterSingletonManagerSettings(
string singletonName,
string role,
TimeSpan removalMargin,
TimeSpan handOverRetryInterval,
LeaseUsageSettings leaseSettings,
bool considerAppVersion)
: this(singletonName, role, removalMargin, handOverRetryInterval, null, considerAppVersion)
: this(singletonName, role, removalMargin, handOverRetryInterval, leaseSettings)
{
}

/// <summary>
/// Creates a new instance of the <see cref="ClusterSingletonManagerSettings"/>.
/// </summary>
Expand All @@ -161,20 +155,77 @@ public ClusterSingletonManagerSettings(
/// over has started or the previous oldest member is removed from the cluster
/// (+ <paramref name="removalMargin"/>).
/// </param>
/// <param name="leaseSettings">LeaseSettings for acquiring before creating the singleton actor</param>
/// <param name="considerAppVersion">
/// Should <see cref="Member.AppVersion"/> be considered when the cluster singleton instance is being moved to another node.
/// When set to false, singleton instance will always be created on oldest member.
/// When set to true, singleton instance will be created on the oldest member with the highest <see cref="Member.AppVersion"/> number.
/// </param>
/// <exception cref="ArgumentException">TBD</exception>
[Obsolete("considerAppVersion is not supported anymore, please use constructor that does not have the considerAppVersion argument. Since 1.5.27")]
public ClusterSingletonManagerSettings(
string singletonName,
string role,
TimeSpan removalMargin,
TimeSpan removalMargin,
TimeSpan handOverRetryInterval,
LeaseUsageSettings leaseSettings,
bool considerAppVersion)
: this(singletonName, role, removalMargin, handOverRetryInterval)
{

}

/// <summary>
/// Creates a new instance of the <see cref="ClusterSingletonManagerSettings"/>.
/// </summary>
/// <param name="singletonName">The actor name of the child singleton actor.</param>
/// <param name="role">
/// Singleton among the nodes tagged with specified role. If the role is not specified
/// it's a singleton among all nodes in the cluster.
/// </param>
/// <param name="removalMargin">
/// Margin until the singleton instance that belonged to a downed/removed partition is
/// created in surviving partition. The purpose of this margin is that in case of
/// a network partition the singleton actors in the non-surviving partitions must
/// be stopped before corresponding actors are started somewhere else.
/// This is especially important for persistent actors.
/// </param>
/// <param name="handOverRetryInterval">
/// When a node is becoming oldest it sends hand-over
/// request to previous oldest, that might be leaving the cluster. This is
/// retried with this interval until the previous oldest confirms that the hand
/// over has started or the previous oldest member is removed from the cluster
/// (+ <paramref name="removalMargin"/>).
/// </param>
/// <exception cref="ArgumentException">TBD</exception>
public ClusterSingletonManagerSettings(string singletonName, string role, TimeSpan removalMargin, TimeSpan handOverRetryInterval)
: this(singletonName, role, removalMargin, handOverRetryInterval, null)
{
}

/// <summary>
/// Creates a new instance of the <see cref="ClusterSingletonManagerSettings"/>.
/// </summary>
/// <param name="singletonName">The actor name of the child singleton actor.</param>
/// <param name="role">
/// Singleton among the nodes tagged with specified role. If the role is not specified
/// it's a singleton among all nodes in the cluster.
/// </param>
/// <param name="removalMargin">
/// Margin until the singleton instance that belonged to a downed/removed partition is
/// created in surviving partition. The purpose of this margin is that in case of
/// a network partition the singleton actors in the non-surviving partitions must
/// be stopped before corresponding actors are started somewhere else.
/// This is especially important for persistent actors.
/// </param>
/// <param name="handOverRetryInterval">
/// When a node is becoming oldest it sends hand-over
/// request to previous oldest, that might be leaving the cluster. This is
/// retried with this interval until the previous oldest confirms that the hand
/// over has started or the previous oldest member is removed from the cluster
/// (+ <paramref name="removalMargin"/>).
/// </param>
/// <param name="leaseSettings">LeaseSettings for acquiring before creating the singleton actor</param>
/// <exception cref="ArgumentException">TBD</exception>
public ClusterSingletonManagerSettings(string singletonName, string role, TimeSpan removalMargin, TimeSpan handOverRetryInterval, LeaseUsageSettings leaseSettings)
{
if (string.IsNullOrWhiteSpace(singletonName))
throw new ArgumentNullException(nameof(singletonName));
Expand All @@ -188,7 +239,6 @@ public ClusterSingletonManagerSettings(
RemovalMargin = removalMargin;
HandOverRetryInterval = handOverRetryInterval;
LeaseSettings = leaseSettings;
ConsiderAppVersion = considerAppVersion;
}

/// <summary>
Expand Down Expand Up @@ -241,21 +291,15 @@ public ClusterSingletonManagerSettings WithLeaseSettings(LeaseUsageSettings leas
return Copy(leaseSettings: leaseSettings);
}

private ClusterSingletonManagerSettings Copy(
string singletonName = null,
Option<string> role = default,
TimeSpan? removalMargin = null,
TimeSpan? handOverRetryInterval = null,
Option<LeaseUsageSettings> leaseSettings = default,
bool? considerAppVersion = null)
private ClusterSingletonManagerSettings Copy(string singletonName = null, Option<string> role = default, TimeSpan? removalMargin = null,
TimeSpan? handOverRetryInterval = null, Option<LeaseUsageSettings> leaseSettings = default)
{
return new ClusterSingletonManagerSettings(
singletonName: singletonName ?? SingletonName,
role: role.HasValue ? role.Value : Role,
removalMargin: removalMargin ?? RemovalMargin,
handOverRetryInterval: handOverRetryInterval ?? HandOverRetryInterval,
leaseSettings: leaseSettings.HasValue ? leaseSettings.Value : LeaseSettings,
considerAppVersion: considerAppVersion ?? ConsiderAppVersion
leaseSettings: leaseSettings.HasValue ? leaseSettings.Value : LeaseSettings
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static Props Props(string singletonManagerPath, ClusterSingletonProxySett
private string _identityId;
private IActorRef _singleton = null;
private ICancelable _identityTimer = null;
private ImmutableSortedSet<Member> _membersByAge;
private ImmutableSortedSet<Member> _membersByAge = ImmutableSortedSet<Member>.Empty.WithComparer(MemberAgeOrdering.Descending);
private ILoggingAdapter _log;

/// <summary>
Expand Down Expand Up @@ -201,7 +201,7 @@ private void HandleInitial(ClusterEvent.CurrentClusterState state)
TrackChanges(() =>
_membersByAge = state.Members
.Where(m => m.Status == MemberStatus.Up && MatchingRole(m))
.ToImmutableSortedSet(_memberAgeComparer));
.ToImmutableSortedSet(MemberAgeOrdering.Descending));
}

// Discard old singleton ActorRef and send a periodic message to self to identify the singleton.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public static ClusterSingletonProxySettings Create(ActorSystem system)
if (config.IsNullOrEmpty())
throw ConfigurationException.NullOrEmptyConfig<ClusterSingletonProxySettings>("akka.cluster.singleton-proxy");

var considerAppVersion =
system.Settings.Config.GetBoolean("akka.cluster.singleton.consider-app-version", false);
return Create(config, considerAppVersion);
return Create(config);
}

/// <summary>
Expand All @@ -44,7 +42,17 @@ public static ClusterSingletonProxySettings Create(ActorSystem system)
/// <param name="config">TBD</param>
/// <param name="considerAppVersion">TBD</param>
/// <returns>TBD</returns>
[Obsolete("considerAppVersion is not supported anymore, please use Create method that does not have the considerAppVersion argument. Since 1.5.27")]
public static ClusterSingletonProxySettings Create(Config config, bool considerAppVersion)
=> Create(config);

/// <summary>
/// Create settings from a configuration with the same layout as
/// the default configuration `akka.cluster.singleton-proxy`.
/// </summary>
/// <param name="config">TBD</param>
/// <returns>TBD</returns>
public static ClusterSingletonProxySettings Create(Config config)
{
if (config.IsNullOrEmpty())
throw ConfigurationException.NullOrEmptyConfig<ClusterSingletonProxySettings>();
Expand All @@ -56,8 +64,7 @@ public static ClusterSingletonProxySettings Create(Config config, bool considerA
singletonName: config.GetString("singleton-name"),
role: role,
singletonIdentificationInterval: config.GetTimeSpan("singleton-identification-interval"),
bufferSize: config.GetInt("buffer-size", 0),
considerAppVersion: considerAppVersion);
bufferSize: config.GetInt("buffer-size", 0));
}

/// <summary>
Expand All @@ -79,13 +86,6 @@ public static ClusterSingletonProxySettings Create(Config config, bool considerA
/// If the location of the singleton is unknown the proxy will buffer this number of messages and deliver them when the singleton is identified.
/// </summary>
public int BufferSize { get; }

/// <summary>
/// Should <see cref="Member.AppVersion"/> be considered when the cluster singleton instance is being moved to another node.
/// When set to false, singleton instance will always be created on oldest member.
/// When set to true, singleton instance will be created on the oldest member with the highest <see cref="Member.AppVersion"/> number.
/// </summary>
public bool ConsiderAppVersion { get; }

/// <summary>
/// Creates new instance of the <see cref="ClusterSingletonProxySettings"/>.
Expand All @@ -109,12 +109,35 @@ public static ClusterSingletonProxySettings Create(Config config, bool considerA
/// or <paramref name="bufferSize"/> is less than or equal to zero.
/// </exception>
/// <exception cref="ArgumentNullException"></exception>
[Obsolete("considerAppVersion is not supported anymore, please use constructor that does not have the considerAppVersion argument. Since 1.5.27")]
public ClusterSingletonProxySettings(
string singletonName,
string role,
TimeSpan singletonIdentificationInterval,
int bufferSize,
TimeSpan singletonIdentificationInterval,
int bufferSize,
bool considerAppVersion)
: this(singletonName, role, singletonIdentificationInterval, bufferSize)
{
}

/// <summary>
/// Creates new instance of the <see cref="ClusterSingletonProxySettings"/>.
/// </summary>
/// <param name="singletonName">The actor name of the singleton actor that is started by the <see cref="ClusterSingletonManager"/>.</param>
/// <param name="role">The role of the cluster nodes where the singleton can be deployed. If None, then any node will do.</param>
/// <param name="singletonIdentificationInterval">Interval at which the proxy will try to resolve the singleton instance.</param>
/// <param name="bufferSize">
/// If the location of the singleton is unknown the proxy will buffer this number of messages and deliver them
/// when the singleton is identified.When the buffer is full old messages will be dropped when new messages
/// are sent via the proxy. Use 0 to disable buffering, i.e.messages will be dropped immediately if the location
/// of the singleton is unknown.
/// </param>
/// <exception cref="ArgumentException">
/// This exception is thrown when either the specified <paramref name="singletonIdentificationInterval"/>
/// or <paramref name="bufferSize"/> is less than or equal to zero.
/// </exception>
/// <exception cref="ArgumentNullException"></exception>
public ClusterSingletonProxySettings(string singletonName, string role, TimeSpan singletonIdentificationInterval, int bufferSize)
{
if (string.IsNullOrEmpty(singletonName))
throw new ArgumentNullException(nameof(singletonName));
Expand All @@ -127,7 +150,6 @@ public ClusterSingletonProxySettings(
Role = role;
SingletonIdentificationInterval = singletonIdentificationInterval;
BufferSize = bufferSize;
ConsiderAppVersion = considerAppVersion;
}

/// <summary>
Expand Down Expand Up @@ -184,19 +206,14 @@ public ClusterSingletonProxySettings WithBufferSize(int bufferSize)
return Copy(bufferSize: bufferSize);
}

private ClusterSingletonProxySettings Copy(
string singletonName = null,
Option<string> role = default,
TimeSpan? singletonIdentificationInterval = null,
int? bufferSize = null,
bool? considerAppVersion = null)
private ClusterSingletonProxySettings Copy(string singletonName = null, Option<string> role = default,
TimeSpan? singletonIdentificationInterval = null, int? bufferSize = null)
{
return new ClusterSingletonProxySettings(
singletonName: singletonName ?? SingletonName,
role: role.HasValue ? role.Value : Role,
singletonIdentificationInterval: singletonIdentificationInterval ?? SingletonIdentificationInterval,
bufferSize: bufferSize ?? BufferSize,
considerAppVersion: considerAppVersion ?? ConsiderAppVersion);
bufferSize: bufferSize ?? BufferSize);
}
}
}
Loading
Loading