-
Notifications
You must be signed in to change notification settings - Fork 1k
/
BenchmarkNode.cs
71 lines (59 loc) · 2.09 KB
/
BenchmarkNode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// //-----------------------------------------------------------------------
// // <copyright file="Seed.cs" company="Akka.NET Project">
// // Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com>
// // Copyright (C) 2013-2022 .NET Foundation <https://github.com/akkadotnet/akka.net>
// // </copyright>
// //-----------------------------------------------------------------------
using System;
using System.Linq;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Configuration;
namespace Akka.Cluster.Cpu.Benchmark
{
public class BenchmarkNode
{
private const string Address = "127.0.0.1";
private const int BasePort = 15225;
public static async Task<int> EntryPoint(string[] args)
{
var node = new BenchmarkNode(int.Parse(args[1]));
node.Start();
// wait forever until we get killed
await Task.Delay(TimeSpan.FromDays(1));
return 0;
}
private readonly Config _config;
private ActorSystem _actorSystem;
public BenchmarkNode(int nodeOffset)
{
_config = ConfigurationFactory.ParseString($@"
akka {{
log-dead-letters = off
log-dead-letters-during-shutdown = off
actor.provider = cluster
remote {{
# log-remote-lifecycle-events = DEBUG
dot-netty.tcp {{
transport-class = ""Akka.Remote.Transport.DotNetty.TcpTransport, Akka.Remote""
applied-adapters = []
transport-protocol = tcp
hostname = ""0.0.0.0""
public-hostname = {Address}
port = {BasePort + nodeOffset}
}}
}}
cluster {{
seed-nodes = [""{new Address("akka.tcp", nameof(BenchmarkNode), Address, BasePort)}""]
roles = [benchmark-node]
}}
}}");
}
public void Start()
{
_actorSystem = ActorSystem.Create(nameof(BenchmarkNode), _config);
}
public async Task StopAsync()
=> await CoordinatedShutdown.Get(_actorSystem).Run(CoordinatedShutdown.ClrExitReason.Instance);
}
}