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

Move ClusterConfiguration to legacy #3901

Merged
merged 15 commits into from Jan 31, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
@@ -1,4 +1,6 @@
using System;
using Orleans.Placement;
using Orleans.Runtime;
using System;
using System.Collections.Generic;
using System.Text;

Expand Down Expand Up @@ -43,21 +45,16 @@ public sealed class UnorderedAttribute : Attribute
/// of preservation of grain state between requests and where multiple activations of the same grain are allowed to be created by the runtime.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public sealed class StatelessWorkerAttribute : Attribute
public sealed class StatelessWorkerAttribute : PlacementAttribute
{
/// <summary>
/// Maximal number of local StatelessWorkers in a single silo.
/// </summary>
public int MaxLocalWorkers { get; private set; }

public StatelessWorkerAttribute(int maxLocalWorkers)
: base(new StatelessWorkerPlacement(maxLocalWorkers))
{
MaxLocalWorkers = maxLocalWorkers;
}

public StatelessWorkerAttribute()
: base(new StatelessWorkerPlacement())
{
MaxLocalWorkers = -1;
}
}

Expand Down Expand Up @@ -91,7 +88,7 @@ public sealed class MayInterleaveAttribute : Attribute

public MayInterleaveAttribute(string callbackMethodName)
{
CallbackMethodName = callbackMethodName;
this.CallbackMethodName = callbackMethodName;
}
}

Expand Down
Expand Up @@ -6,18 +6,5 @@ namespace Orleans.Runtime
internal class ActivationCountBasedPlacement : PlacementStrategy
{
internal static ActivationCountBasedPlacement Singleton { get; } = new ActivationCountBasedPlacement();

private ActivationCountBasedPlacement()
{}

public override bool Equals(object obj)
{
return obj is ActivationCountBasedPlacement;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason of removing these methods? no usage of them? meaningless overrides, because it is using the base implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was just useless noise. Ran across it when trying to understand how strategies where used. Killed it because it just created confusion and was pointless.

public override int GetHashCode()
{
return GetType().GetHashCode();
}
}
}
18 changes: 1 addition & 17 deletions src/Orleans.Core.Abstractions/Placement/HashBasedPlacement.cs
@@ -1,26 +1,10 @@
using System;
using System;

namespace Orleans.Runtime
{
[Serializable]
internal class HashBasedPlacement : PlacementStrategy
{

internal static HashBasedPlacement Singleton { get; } = new HashBasedPlacement();


public HashBasedPlacement()
{
}

public override bool Equals(object obj)
{
return obj is HashBasedPlacement;
}

public override int GetHashCode()
{
return GetType().GetHashCode();
}
}
}
Expand Up @@ -16,7 +16,7 @@ protected PlacementAttribute(PlacementStrategy placement)
{
if (placement == null) throw new ArgumentNullException(nameof(placement));

PlacementStrategy = placement;
this.PlacementStrategy = placement;
}
}

Expand Down
13 changes: 0 additions & 13 deletions src/Orleans.Core.Abstractions/Placement/PreferLocalPlacement.cs
Expand Up @@ -6,18 +6,5 @@ namespace Orleans.Runtime
internal class PreferLocalPlacement : PlacementStrategy
{
internal static PreferLocalPlacement Singleton { get; } = new PreferLocalPlacement();

private PreferLocalPlacement()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why these changes?

{ }

public override bool Equals(object obj)
{
return obj is PreferLocalPlacement;
}

public override int GetHashCode()
{
return GetType().GetHashCode();
}
}
}
13 changes: 0 additions & 13 deletions src/Orleans.Core.Abstractions/Placement/RandomPlacement.cs
Expand Up @@ -6,18 +6,5 @@ namespace Orleans.Runtime
internal class RandomPlacement : PlacementStrategy
{
internal static RandomPlacement Singleton { get; } = new RandomPlacement();

private RandomPlacement()
{ }

public override bool Equals(object obj)
{
return obj is RandomPlacement;
}

public override int GetHashCode()
{
return GetType().GetHashCode();
}
}
}
Expand Up @@ -5,32 +5,20 @@ namespace Orleans.Runtime
[Serializable]
internal class StatelessWorkerPlacement : PlacementStrategy
{
private static readonly int defaultMaxStatelessWorkers = Environment.ProcessorCount;
private static readonly int DefaultMaxStatelessWorkers = Environment.ProcessorCount;

public int MaxLocal { get; private set; }

internal StatelessWorkerPlacement(int maxLocal = -1)
{
// If maxLocal was not specified on the StatelessWorkerAttribute,
// we will use the defaultMaxStatelessWorkers, which is System.Environment.ProcessorCount.
MaxLocal = maxLocal > 0 ? maxLocal : defaultMaxStatelessWorkers;
this.MaxLocal = maxLocal > 0 ? maxLocal : DefaultMaxStatelessWorkers;
}

public override string ToString()
{
return String.Format("StatelessWorkerPlacement(max={0})", MaxLocal);
}

public override bool Equals(object obj)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more noise

{
var other = obj as StatelessWorkerPlacement;
return other != null && MaxLocal == other.MaxLocal;
}

public override int GetHashCode()
{
return GetType().GetHashCode() ^ MaxLocal.GetHashCode();
return string.Format("StatelessWorkerPlacement(max={0})", this.MaxLocal);
}
}

}
@@ -1,23 +1,10 @@
using System;
using System;

namespace Orleans.Versions.Compatibility
{
[Serializable]
public class AllVersionsCompatible : CompatibilityStrategy
{
public static AllVersionsCompatible Singleton { get; } = new AllVersionsCompatible();

private AllVersionsCompatible()
{ }

public override bool Equals(object obj)
{
return obj is AllVersionsCompatible;
}

public override int GetHashCode()
{
return GetType().GetHashCode();
}
}
}
Expand Up @@ -6,18 +6,5 @@ namespace Orleans.Versions.Compatibility
public class BackwardCompatible : CompatibilityStrategy
{
public static BackwardCompatible Singleton { get; } = new BackwardCompatible();

private BackwardCompatible()
{ }

public override bool Equals(object obj)
{
return obj is BackwardCompatible;
}

public override int GetHashCode()
{
return GetType().GetHashCode();
}
}
}
@@ -1,4 +1,4 @@
using System;
using System;

namespace Orleans.Versions.Compatibility
{
Expand All @@ -7,22 +7,8 @@ public interface ICompatibilityDirector
bool IsCompatible(ushort requestedVersion, ushort currentVersion);
}

public interface ICompatibilityDirector<TStrategy> : ICompatibilityDirector where TStrategy : CompatibilityStrategy
{
}

[Serializable]
public abstract class CompatibilityStrategy
{
public static CompatibilityStrategy Parse(string str)
{
if (str.Equals(typeof(AllVersionsCompatible).Name))
return AllVersionsCompatible.Singleton;
if (str.Equals(typeof(BackwardCompatible).Name))
return BackwardCompatible.Singleton;
if (str.Equals(typeof(StrictVersionCompatible).Name))
return StrictVersionCompatible.Singleton;
return null;
}
}
}
@@ -1,23 +1,10 @@
using System;
using System;

namespace Orleans.Versions.Compatibility
{
[Serializable]
public class StrictVersionCompatible : CompatibilityStrategy
{
public static StrictVersionCompatible Singleton { get; } = new StrictVersionCompatible();

private StrictVersionCompatible()
{ }

public override bool Equals(object obj)
{
return obj is StrictVersionCompatible;
}

public override int GetHashCode()
{
return GetType().GetHashCode();
}
}
}
Expand Up @@ -6,18 +6,5 @@ namespace Orleans.Versions.Selector
public class AllCompatibleVersions : VersionSelectorStrategy
{
public static AllCompatibleVersions Singleton { get; } = new AllCompatibleVersions();

private AllCompatibleVersions()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter. These classes are just marker.

{ }

public override bool Equals(object obj)
{
return obj is AllCompatibleVersions;
}

public override int GetHashCode()
{
return GetType().GetHashCode();
}
}
}
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Orleans.Versions.Compatibility;

Expand All @@ -9,22 +9,8 @@ public interface IVersionSelector
IReadOnlyList<ushort> GetSuitableVersion(ushort requestedVersion, IReadOnlyList<ushort> availableVersions, ICompatibilityDirector compatibilityDirector);
}

public interface IVersionSelector<TPolicy> : IVersionSelector where TPolicy : VersionSelectorStrategy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you remove this interface ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These interfaces existed only to provide mappings from strategy types to other implementations, which requires reflection and is somewhat clumsy. Replaced this with typed services using type as key.

{
}

[Serializable]
public abstract class VersionSelectorStrategy
{
public static VersionSelectorStrategy Parse(string str)
{
if (str.Equals(typeof(AllCompatibleVersions).Name))
return AllCompatibleVersions.Singleton;
if (str.Equals(typeof(LatestVersion).Name))
return LatestVersion.Singleton;
if (str.Equals(typeof(MinimumVersion).Name))
return MinimumVersion.Singleton;
return null;
}
}
}
15 changes: 1 addition & 14 deletions src/Orleans.Core.Abstractions/Versions/Selector/LatestVersion.cs
@@ -1,23 +1,10 @@
using System;
using System;

namespace Orleans.Versions.Selector
{
[Serializable]
public class LatestVersion : VersionSelectorStrategy
{
public static LatestVersion Singleton { get; } = new LatestVersion();

private LatestVersion()
{ }

public override bool Equals(object obj)
{
return obj is LatestVersion;
}

public override int GetHashCode()
{
return GetType().GetHashCode();
}
}
}
@@ -1,23 +1,10 @@
using System;
using System;

namespace Orleans.Versions.Selector
{
[Serializable]
public class MinimumVersion : VersionSelectorStrategy
{
public static MinimumVersion Singleton { get; } = new MinimumVersion();

private MinimumVersion()
{ }

public override bool Equals(object obj)
{
return obj is MinimumVersion;
}

public override int GetHashCode()
{
return GetType().GetHashCode();
}
}
}