public void Setup(BenchmarkContext context) { _remoteMessageThroughput = context.GetCounter(RemoteMessageCounterName); System1 = ActorSystem.Create("SystemA" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemA" + ActorSystemNameCounter.Current, "127.0.0.1", 0)); _echo = System1.ActorOf(Props.Create(() => new EchoActor()), "echo"); System2 = ActorSystem.Create("SystemB" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemB" + ActorSystemNameCounter.Current, "127.0.0.1", 0)); _receiver = System2.ActorOf( Props.Create(() => new BenchmarkActor(_remoteMessageThroughput, RemoteMessageCount, _resetEvent)), "benchmark"); var system1Address = RARP.For(System1).Provider.Transport.DefaultAddress; var system2Address = RARP.For(System2).Provider.Transport.DefaultAddress; var system1EchoActorPath = new RootActorPath(system1Address) / "user" / "echo"; var system2RemoteActorPath = new RootActorPath(system2Address) / "user" / "benchmark"; try { // set the timeout high here to avoid timeouts // TL;DR; - on slow machines it can take longer than 2 seconds to form the association, do the handshake, and reply back // using the in-memory transport. _remoteReceiver = System1.ActorSelection(system2RemoteActorPath).ResolveOne(TimeSpan.FromSeconds(30)).Result; _remoteEcho = System2.ActorSelection(system1EchoActorPath).ResolveOne(TimeSpan.FromSeconds(2)).Result; } catch (Exception ex) { context.Trace.Error(ex, "error occurred during setup."); throw; // re-throw the error to blow up the benchmark } }
public LifeCycleTest2Actor(IActorRef testActor, string id, AtomicCounter generationProvider) { this.testActor = testActor; this.id = id; this.generationProvider = generationProvider; this.CurrentGeneration = generationProvider.Next(); }
public void ShouldIncrementByDefaultStep() { var counter = new AtomicCounter(1); int actual = counter.Next(); Assert.AreEqual(2, actual); }
public LifeCycleTest2Actor(IActorRef testActor, string id, AtomicCounter generationProvider) { this.testActor = testActor; this.id = id; this.generationProvider = generationProvider; this.CurrentGeneration = generationProvider.Next(); }
public void ShouldIncrementBySpecifiedStep() { var counter = new AtomicCounter(1, 100); int actual = counter.Next(); Assert.AreEqual(101, actual); }
private void Dispose(bool isDisposing) { if (!WasDisposed) { WasDisposed = true; _disposeCounter.Next(); } }
public void Setup(BenchmarkContext context) { _remoteMessageThroughput = context.GetCounter(RemoteMessageCounterName); System1 = ActorSystem.Create("SystemA" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemA" + ActorSystemNameCounter.Current, "127.0.0.1", 0)); System2 = ActorSystem.Create("SystemB" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemB" + ActorSystemNameCounter.Current, "127.0.0.1", 0)); var system1Address = RARP.For(System1).Provider.Transport.DefaultAddress; var system2Address = RARP.For(System2).Provider.Transport.DefaultAddress; var canStart = System2.ActorOf(Props.Create(() => new AllStartedActor()), "canStart"); var echoProps = Props.Create(() => new EchoActor()).WithDeploy(new Deploy(new RemoteScope(system1Address))); for (var i = 0; i < NumClients; i++) { var echo = System2.ActorOf(echoProps, "echo" + i); var ts = new TaskCompletionSource <long>(); _tasks.Add(ts.Task); var receiver = System2.ActorOf( Props.Create(() => new BenchmarkActor(_remoteMessageThroughput, RemoteMessageCount, ts, echo)), "benchmark" + i); _receivers.Add(receiver); canStart.Tell(echo); canStart.Tell(receiver); } try { var testReady = canStart.Ask <bool>(new AllStartedActor.AllStarted(), TimeSpan.FromSeconds(10)).Result; if (!testReady) { throw new NBenchException("Received report that 1 or more remote actor is unable to begin the test. Aborting run."); } } catch (Exception ex) { context.Trace.Error(ex, "error occurred during setup."); throw; // re-throw the error to blow up the benchmark } }
public void AssociationStress(BenchmarkContext context) { var registryKey = CreateRegistryKey(); using ( var system1 = ActorSystem.Create("SystemA" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemA" + ActorSystemNameCounter.Current, "127.0.0.1", 0, registryKey))) using ( var system2 = ActorSystem.Create("SystemB" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemB" + ActorSystemNameCounter.Current, "127.0.0.1", 0, registryKey))) { var echo = system1.ActorOf(ActorProps, "echo"); var system1Address = RARP.For(system1).Provider.Transport.DefaultAddress; var system1EchoActorPath = new RootActorPath(system1Address) / "user" / "echo"; var remoteActor = system2.ActorSelection(system1EchoActorPath) .Ask <ActorIdentity>(new Identify(null), TimeSpan.FromSeconds(2)).Result.Subject; AssociationCounter.Increment(); } }
public void Setup(BenchmarkContext context) { _remoteMessageThroughput = context.GetCounter(RemoteMessageCounterName); System1 = ActorSystem.Create("SystemA" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemA" + ActorSystemNameCounter.Current, "127.0.0.1", 0)); _echo = System1.ActorOf(Props.Create(() => new EchoActor()), "echo"); System2 = ActorSystem.Create("SystemB" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemB" + ActorSystemNameCounter.Current, "127.0.0.1", 0)); _receiver = System2.ActorOf( Props.Create(() => new BenchmarkActor(_remoteMessageThroughput, RemoteMessageCount, _resetEvent)), "benchmark"); var system1Address = RARP.For(System1).Provider.Transport.DefaultAddress; var system2Address = RARP.For(System2).Provider.Transport.DefaultAddress; var system1EchoActorPath = new RootActorPath(system1Address) / "user" / "echo"; var system2RemoteActorPath = new RootActorPath(system2Address) / "user" / "benchmark"; _remoteReceiver = System1.ActorSelection(system2RemoteActorPath).ResolveOne(TimeSpan.FromSeconds(2)).Result; _remoteEcho = System2.ActorSelection(system1EchoActorPath).ResolveOne(TimeSpan.FromSeconds(2)).Result; }
private void StartTimer(object key, object msg, TimeSpan timeout, TimeSpan initialDelay, bool repeat) { if (timers.TryGetValue(key, out var timer)) { CancelTimer(timer); } var nextGen = timerGen.Next(); ITimerMsg timerMsg; if (msg is INotInfluenceReceiveTimeout) { timerMsg = new TimerMsgNotInfluenceReceiveTimeout(key, nextGen, this); } else { timerMsg = new TimerMsg(key, nextGen, this); } ICancelable task; if (repeat) { task = ctx.System.Scheduler.ScheduleTellRepeatedlyCancelable(initialDelay, timeout, ctx.Self, timerMsg, ActorRefs.NoSender); } else { task = ctx.System.Scheduler.ScheduleTellOnceCancelable(timeout, ctx.Self, timerMsg, ActorRefs.NoSender); } var nextTimer = new Timer(key, msg, repeat, nextGen, task); ctx.System.Log.Debug("Start timer [{0}] with generation [{1}]", key, timerGen); timers[key] = nextTimer; }
public void ShouldIncrementBySpecifiedStep() { var counter = new AtomicCounter(1, 100); int actual = counter.Next(); Assert.AreEqual(101, actual); }
public void ShouldIncrementByDefaultStep() { var counter = new AtomicCounter(1); int actual = counter.Next(); Assert.AreEqual(2, actual); }