Skip to content

Commit

Permalink
[PORT #6366] set default PoolRouter SupervisorStrategy to Restart (#6370
Browse files Browse the repository at this point in the history
)

* close #6295 - set default PoolRouter SupervisorStrategy to Restart (#6366)

* close #6295 - set default PoolRouter SupervisorStrategy to Restart
* use the `SupervisionStrategy.DefaultStrategy`
* Fix unit test
* Change unit test to use RoundRobinPool router

(cherry-picked from ffd9a9e)

* Fix actor telemetry unit test

---------

Co-authored-by: Aaron Stannard <aaron@petabridge.com>
  • Loading branch information
Arkatufus and Aaronontheweb committed Jan 30, 2023
1 parent d3b89da commit 8dfa8f8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
5 changes: 2 additions & 3 deletions src/core/Akka.Tests/Actor/ActorTelemetrySpecs.cs
Expand Up @@ -283,8 +283,7 @@ public async Task ActorTelemetry_must_be_accurate_for_pool_router()
// assert that actor start count is still 10
Assert.Equal(12, telemetry.ActorCreated);
// bug due to https://github.com/akkadotnet/akka.net/issues/6295 - all routees and the router start each time
Assert.Equal(110, telemetry.ActorRestarted);
Assert.Equal(10, telemetry.ActorRestarted);
// assert no stops recorded
Assert.Equal(0, telemetry.ActorStopped);
}, RemainingOrDefault);
Expand All @@ -296,7 +295,7 @@ public async Task ActorTelemetry_must_be_accurate_for_pool_router()
var telemetry = await subscriber.Ask<TelemetrySubscriber.GetTelemetry>(TelemetrySubscriber.GetTelemetryRequest.Instance);
// assert that actor start count is still 10
Assert.Equal(12, telemetry.ActorCreated);
Assert.Equal(110, telemetry.ActorRestarted);
Assert.Equal(10, telemetry.ActorRestarted);
Assert.Equal(11, telemetry.ActorStopped);
}, RemainingOrDefault);
}
Expand Down
27 changes: 10 additions & 17 deletions src/core/Akka.Tests/Routing/RoutingSpec.cs
Expand Up @@ -294,27 +294,20 @@ public async Task Routers_in_general_must_set_supplied_supervisorStrategy_for_Fr
}

[Fact]
public async Task Routers_in_general_must_default_to_all_for_one_always_escalate_strategy()
public void Routers_in_general_must_default_to_all_for_one_restart_strategy()
{
var restarter = new OneForOneStrategy(e =>
{
TestActor.Tell(e);
return Directive.Restart;
});

var supervisor = Sys.ActorOf(Props.Create(() => new Supervisor(restarter)));
var router = Sys.ActorOf(new RoundRobinPool(3).Props(Props.Create(() => new RestartActor(TestActor))));
var restarted = new HashSet<string>();

supervisor.Tell(new RoundRobinPool(3).Props(Props.Create(() => new RestartActor(TestActor))));

var router = await ExpectMsgAsync<IActorRef>();
await EventFilter.Exception<ArgumentException>("die").ExpectOneAsync(async () =>
for (var i = 0; i < 3; i++)
{
router.Tell("die");
});
(await ExpectMsgAsync<ArgumentException>()).Message.Should().Be("die");
await ExpectMsgAsync("restarted");
await ExpectMsgAsync("restarted");
await ExpectMsgAsync("restarted");
ExpectMsg("restarted");
restarted.Add(LastSender.Path.Name);
}

restarted.Count.Should().Be(3);
restarted.Should().BeEquivalentTo(((RoutedActorRef)router).Children.Select(c => c.Path.Name));
}

[Fact]
Expand Down
10 changes: 2 additions & 8 deletions src/core/Akka/Routing/RouterConfig.cs
Expand Up @@ -354,15 +354,9 @@ public override ActorBase CreateRouterActor()
/// <summary>
/// TBD
/// </summary>
public static SupervisorStrategy DefaultSupervisorStrategy
{
get
{
return new OneForOneStrategy(Decider.From(Directive.Escalate));
}
}
public static SupervisorStrategy DefaultSupervisorStrategy => SupervisorStrategy.DefaultStrategy;



public bool Equals(Pool other)
{
if (ReferenceEquals(null, other)) return false;
Expand Down

0 comments on commit 8dfa8f8

Please sign in to comment.