コード例 #1
0
 public override void Setup(BenchmarkContext context)
 {
     base.Setup(context);
     _recoveryCounter = context.GetCounter(RecoveryCounterName);
     StoreAllEvents();
     Supervisor.Ask <AllTerminated>(new TerminateAll(), TimeSpan.FromSeconds(10)).GetAwaiter().GetResult();
 }
        protected Task <PersistentBenchmarkMsgs.Finished>[] RecoverAllEvents()
        {
            var recovered = new Task <PersistentBenchmarkMsgs.Finished> [PersistentActorCount];

            for (int i = 0; i < PersistentActorCount; i++)
            {
                var task = Supervisor
                           .Ask <PersistentBenchmarkMsgs.Finished>(new BenchmarkActorMessage(PersistentActorIds[i], PersistentBenchmarkMsgs.Finish.Instance), MaxTimeout);

                recovered[i] = task;
            }

            Task.WaitAll(recovered.Cast <Task>().ToArray());
            return(recovered);
        }
        protected Task <PersistentBenchmarkMsgs.TookSnapshot>[] StoreSnapshotForEachActor()
        {
            var finished = new Task <PersistentBenchmarkMsgs.TookSnapshot> [PersistentActorCount];

            for (int i = 0; i < PersistentActorCount; i++)
            {
                var msg  = new BenchmarkActorMessage(PersistentActorIds[i], new PersistentBenchmarkMsgs.TakeSnapshot("snapshot"));
                var task = Supervisor
                           .Ask <PersistentBenchmarkMsgs.TookSnapshot>(msg, MaxTimeout);

                finished[i] = task;
            }

            Task.WaitAll(finished.Cast <Task>().ToArray());

            return(finished);
        }
        public void SnapshotLoadSpec(BenchmarkContext context)
        {
            var finished = new Task <PersistentBenchmarkMsgs.Finished> [PersistentActorCount];

            for (int i = 0; i < PersistentActorCount; i++)
            {
                var task = Supervisor
                           .Ask <PersistentBenchmarkMsgs.Finished>(new BenchmarkActorMessage(PersistentActorIds[i], PersistentBenchmarkMsgs.Finish.Instance), MaxTimeout);

                finished[i] = task;
            }

            Task.WaitAll(finished.Cast <Task>().ToArray());

            foreach (var task in finished.Where(x => x.IsCompleted))
            {
                _recoveryCounter.Increment(task.Result.State);
                _snapshotLoadCounter.Increment(1);
            }
        }
コード例 #5
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="props">TBD</param>
        /// <param name="name">TBD</param>
        /// <param name="dispatcher">TBD</param>
        /// <exception cref="IllegalStateException">TBD</exception>
        /// <returns>TBD</returns>
        protected IActorRef ActorOf(Props props, string name, string dispatcher)
        {
            if (Supervisor is LocalActorRef)
            {
                var aref = (LocalActorRef)Supervisor;
                return(((ActorCell)aref.Underlying).AttachChild(props.WithDispatcher(dispatcher), isSystemService: false, name: name));
            }
            if (Supervisor is RepointableActorRef)
            {
                var aref = (RepointableActorRef)Supervisor;
                if (aref.IsStarted)
                {
                    return(((ActorCell)aref.Underlying).AttachChild(props.WithDispatcher(dispatcher), isSystemService: false, name: name));
                }

                var timeout = aref.Underlying.System.Settings.CreationTimeout;
                var f       = Supervisor.Ask <IActorRef>(new StreamSupervisor.Materialize(props.WithDispatcher(dispatcher), name), timeout);
                return(f.Result);
            }
            throw new IllegalStateException($"Stream supervisor must be a local actor, was [{Supervisor.GetType()}]");
        }
        protected Task <PersistentBenchmarkMsgs.Finished>[] StoreAllEvents()
        {
            for (int i = 0; i < PersistedMessageCount; i++)
            {
                for (int j = 0; j < PersistentActorCount; j++)
                {
                    Supervisor.Tell(new BenchmarkActorMessage(PersistentActorIds[j], new PersistentBenchmarkMsgs.Store(1)));
                }
            }

            var finished = new Task <PersistentBenchmarkMsgs.Finished> [PersistentActorCount];

            for (int i = 0; i < PersistentActorCount; i++)
            {
                var task = Supervisor
                           .Ask <PersistentBenchmarkMsgs.Finished>(new BenchmarkActorMessage(PersistentActorIds[i], PersistentBenchmarkMsgs.Finish.Instance), MaxTimeout);

                finished[i] = task;
            }

            Task.WaitAll(finished.Cast <Task>().ToArray());

            return(finished);
        }