Skip to content

Commit

Permalink
Merge branch 'v1.3' into routing_refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb authored Jun 6, 2017
2 parents 85335bf + d7ce425 commit 5c2b556
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,7 @@ namespace Akka.Actor
public TerminatedProps() { }
public override Akka.Actor.ActorBase NewActor() { }
}
[System.ObsoleteAttribute("TypedActor in its current shape will be removed in v1.5")]
public abstract class TypedActor : Akka.Actor.ActorBase
{
protected TypedActor() { }
Expand Down
4 changes: 3 additions & 1 deletion src/core/Akka.Cluster.Tests/ActorRefProvidersConfigSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ public void ActorProviderConfig_should_resolve_cluster_alias()

private void ConfigureAndVerify(string alias, Type actorProviderType)
{
var config = ConfigurationFactory.ParseString(@"akka.actor.provider = " + alias);
var config = ConfigurationFactory.ParseString(@"akka.actor.provider = " + alias)
.WithFallback(ConfigurationFactory.ParseString("akka.remote.dot-netty.tcp.port = 0")); // use a random port to avoid issues with async and parallelization
using (var system = ActorSystem.Create(nameof(ActorRefProvidersConfigSpec), config))
{
var ext = (ExtendedActorSystem) system;
ext.Provider.GetType().ShouldBe(actorProviderType);
system.Terminate().Wait(TimeSpan.FromSeconds(3)); // force the system to cleanup and shutdown
}
}
}
Expand Down
32 changes: 18 additions & 14 deletions src/core/Akka.Cluster.Tests/ClusterSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ namespace Akka.Cluster.Tests
{
public class ClusterSpec : AkkaSpec
{

/*
* Portability note: all of the _cluster.Join(selfAddress) calls are necessary here, whereas they are not in the JVM
* because the JVM test suite relies on side-effects from one test to another, whereas all of our tests are fully isolated.
*/

const string Config = @"
akka.cluster {
auto-down-unreachable-after = 0s
Expand All @@ -46,7 +52,7 @@ public ClusterSpec()
_cluster = Cluster.Get(Sys);
}

public void LeaderActions()
internal void LeaderActions()
{
_cluster.ClusterCore.Tell(InternalClusterAction.LeaderActionsTick.Instance);
}
Expand Down Expand Up @@ -89,7 +95,6 @@ public void A_cluster_must_publish_initial_state_as_events_to_subscribers()
{
try
{
// TODO: this should be removed
_cluster.Join(_selfAddress);
LeaderActions(); // Joining -> Up

Expand All @@ -113,7 +118,6 @@ public void A_cluster_must_send_current_cluster_state_to_one_receiver_when_reque
[Fact]
public void A_cluster_must_publish_member_removed_when_shutdown()
{
// TODO: this should be removed
_cluster.Join(_selfAddress);
LeaderActions(); // Joining -> Up

Expand All @@ -139,7 +143,6 @@ public void A_cluster_must_publish_member_removed_when_shutdown()
[Fact]
public void BugFix_2442_RegisterOnMemberUp_should_fire_if_node_already_up()
{
// TODO: this should be removed
_cluster.Join(_selfAddress);
LeaderActions(); // Joining -> Up

Expand Down Expand Up @@ -182,15 +185,16 @@ public void A_cluster_must_complete_LeaveAsync_task_upon_being_removed()

AwaitCondition(() => leaveTask.IsCompleted);

// A second call for LeaveAsync should complete immediately
// A second call for LeaveAsync should complete immediately (should be the same task as before)
Cluster.Get(sys2).LeaveAsync().IsCompleted.Should().BeTrue();
}

#if CORECLR
[Fact(Skip = "Fails on .NET Core")]
#else
[Fact(Skip = "Fails flakily on .NET 4.5")]
#endif
//#if CORECLR
// [Fact(Skip = "Fails on .NET Core")]
//#else
// [Fact(Skip = "Fails flakily on .NET 4.5")]
//#endif
[Fact]
public void A_cluster_must_return_completed_LeaveAsync_task_if_member_already_removed()
{
// Join cluster
Expand All @@ -214,7 +218,7 @@ public void A_cluster_must_return_completed_LeaveAsync_task_if_member_already_re
});

// LeaveAsync() task expected to complete immediately
_cluster.LeaveAsync().IsCompleted.Should().BeTrue();
AwaitCondition(() => _cluster.LeaveAsync().IsCompleted);
}

[Fact]
Expand All @@ -237,7 +241,7 @@ public void A_cluster_must_cancel_LeaveAsync_task_if_CancellationToken_fired_bef

// Cancelling the first task
cts.Cancel();
task1.Should(t => t.IsCanceled, "Task should be cancelled.");
AwaitCondition(() => task1.IsCanceled, null, "Task should be cancelled");

Within(TimeSpan.FromSeconds(10), () =>
{
Expand All @@ -252,12 +256,12 @@ public void A_cluster_must_cancel_LeaveAsync_task_if_CancellationToken_fired_bef
ExpectMsg<ClusterEvent.MemberRemoved>().Member.Address.Should().Be(_selfAddress);

// Second task should complete (not cancelled)
task2.Should(t => t.IsCompleted && !t.IsCanceled, "Task should be completed, but not cancelled.");
AwaitCondition(() => task2.IsCompleted && !task2.IsCanceled, null, "Task should be completed, but not cancelled.");
});

// Subsequent LeaveAsync() tasks expected to complete immediately (not cancelled)
var task3 = _cluster.LeaveAsync();
task3.Should(t => t.IsCompleted && !t.IsCanceled, "Task should be completed, but not cancelled.");
AwaitCondition(() => task3.IsCompleted && !task3.IsCanceled, null, "Task should be completed, but not cancelled.");
}

[Fact]
Expand Down
18 changes: 10 additions & 8 deletions src/core/Akka.Cluster.Tests/DowningProviderSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class DowningProviderSpec : AkkaSpec
loglevel = WARNING
actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
remote {
netty.tcp {
dot-netty.tcp {
hostname = ""127.0.0.1""
port = 0
}
Expand Down Expand Up @@ -95,7 +95,7 @@ public void Downing_provider_should_use_specified_downing_provider()
{
var downingProvider = Cluster.Get(system).DowningProvider;
downingProvider.Should().BeOfType<DummyDowningProvider>();
AwaitCondition(() =>
AwaitCondition(() =>
(downingProvider as DummyDowningProvider).ActorPropsAccessed.Value,
TimeSpan.FromSeconds(3));
}
Expand All @@ -106,13 +106,15 @@ public void Downing_provider_should_stop_the_cluster_if_the_downing_provider_thr
{
var config = ConfigurationFactory.ParseString(
@"akka.cluster.downing-provider-class = ""Akka.Cluster.Tests.FailingDowningProvider, Akka.Cluster.Tests""");
using (var system = ActorSystem.Create("auto-downing", config.WithFallback(BaseConfig)))
{
var cluster = Cluster.Get(system);
cluster.Join(cluster.SelfAddress);

AwaitCondition(() => cluster.IsTerminated, TimeSpan.FromSeconds(3));
}
var system = ActorSystem.Create("auto-downing", config.WithFallback(BaseConfig));

var cluster = Cluster.Get(system);
cluster.Join(cluster.SelfAddress);

AwaitCondition(() => cluster.IsTerminated, TimeSpan.FromSeconds(3));

Shutdown(system);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.TestKit/Internal/Reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ akka {
# to use EventFiltering. If no filter is specified it logs to StdOut just like
# DefaultLogger.
loggers = ["Akka.TestKit.TestEventListener, Akka.TestKit"]

suppress-json-serializer-warning = true
test {
# factor by which to scale timeouts during tests, e.g. to account for shared
# build system load
Expand Down
4 changes: 2 additions & 2 deletions src/core/Akka.Tests/Routing/TailChoppingSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public void Tail_chopping_group_router_must_return_response_from_second_actor_af
[Fact]
public void Tail_chopping_group_router_must_throw_exception_if_no_result_will_arrive_within_the_given_time()
{
var actor1 = Sys.ActorOf(Props.Create(() => new TailChopTestActor(500.Milliseconds())), "Actor3");
var actor2 = Sys.ActorOf(Props.Create(() => new TailChopTestActor(500.Milliseconds())), "Actor4");
var actor1 = Sys.ActorOf(Props.Create(() => new TailChopTestActor(1500.Milliseconds())), "Actor3");
var actor2 = Sys.ActorOf(Props.Create(() => new TailChopTestActor(1500.Milliseconds())), "Actor4");

var probe = CreateTestProbe();
var paths = new List<string> { actor1.Path.ToString(), actor2.Path.ToString() };
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka/Actor/ActorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private void Dispose(bool disposing)
}
finally
{
// base.dispose(disposing);

}
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/Akka/Actor/TypedActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Reflection;

namespace Akka.Actor
Expand All @@ -25,6 +26,7 @@ public interface IHandle<in TMessage>
/// <summary>
/// Class TypedActor.
/// </summary>
[Obsolete("TypedActor in its current shape will be removed in v1.5")]
public abstract class TypedActor : ActorBase
{
/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion src/core/Akka/Helios.Concurrency.DedicatedThreadPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ private sealed class UnfairSemaphore
{
public const int MaxWorker = 0x7FFF;

private static readonly int ProcessorCount = Environment.ProcessorCount;

// We track everything we care about in a single 64-bit struct to allow us to
// do CompareExchanges on this for atomic updates.
[StructLayout(LayoutKind.Explicit)]
Expand Down Expand Up @@ -679,7 +681,7 @@ public bool Wait(TimeSpan timeout)
}
else
{
double spinnersPerProcessor = (double)currentCounts.Spinners / Environment.ProcessorCount;
double spinnersPerProcessor = (double)currentCounts.Spinners / ProcessorCount;
int spinLimit = (int)((spinLimitPerProcessor / spinnersPerProcessor) + 0.5);
if (numSpins >= spinLimit)
{
Expand Down

0 comments on commit 5c2b556

Please sign in to comment.