public void Can_serialize_Supervise()
        {
            var       actorRef     = ActorOf <BlackHoleActor>();
            var       supervise    = new Supervise(actorRef, true);
            Supervise deserialized = AssertAndReturn(supervise);

            deserialized.Child.Should().Be(actorRef);
            deserialized.Async.Should().Be(supervise.Async);
        }
Exemple #2
0
        //
        // Supervise
        //
        private byte[] SuperviseToProto(Supervise supervise)
        {
            var message = new Proto.Msg.SuperviseData();

            message.Child      = new Proto.Msg.ActorRefData();
            message.Child.Path = Akka.Serialization.Serialization.SerializedActorPath(supervise.Child);
            message.Async      = supervise.Async;
            return(message.ToByteArray());
        }
        /// <summary>
        ///     Handles the supervise.
        /// </summary>
        /// <param name="m">The m.</param>
        private void HandleSupervise(Supervise m)
        {
            //TODO: complete this
            //  if (!isTerminating) {
            // Supervise is the first thing we get from a new child, so store away the UID for later use in handleFailure()

            //   initChild(child) match {
            //     case Some(crs) ⇒
            //       handleSupervise(child, async)
            if (System.Settings.DebugLifecycle)
            {
                Publish(new Debug(Self.Path.ToString(), ActorType, "now supervising " + m.Child.Path));
            }
            //     case None ⇒ publish(Error(self.path.toString, clazz(actor), "received Supervise from unregistered child " + child + ", this will not end well"))
        }
Exemple #4
0
        public IDictionary <string, Role> GetRoles()
        {
            IDictionary <string, Role> roles = new Dictionary <string, Role>();

            string cmdText = @"select * from AspNetRoles";

            this.ReadData(dataReader =>
            {
                string key  = dataReader["Id"].ToString();
                string name = dataReader["Name"].ToString();

                if (Enum.TryParse(name, out RoleType result))
                {
                    switch (result)
                    {
                    case RoleType.Administrator:
                        roles.Add(key, Administrator.GetInstance());
                        break;

                    case RoleType.Customer:
                        roles.Add(key, WebApplication.Models.Role.Customer.GetInstance());
                        break;

                    case RoleType.DirectStore:
                        roles.Add(key, DirectStore.GetInstance());
                        break;

                    case RoleType.Guidance:
                        roles.Add(key, Guidance.GetInstance());
                        break;

                    case RoleType.Supervise:
                        roles.Add(key, Supervise.GetInstance());
                        break;

                    case RoleType.VIP:
                        roles.Add(key, VIP.GetInstance());
                        break;

                    case RoleType.VVIP:
                        roles.Add(key, VVIP.GetInstance());
                        break;
                    }
                }
            }, cmdText);

            return(roles);
        }
Exemple #5
0
        public Task Consume(ConsumeContext <SuperviseJob> context)
        {
            JobHandle jobHandle;

            if (_roster.TryGetJob(context.Message.JobId, out jobHandle))
            {
                switch (jobHandle.Status)
                {
                case JobStatus.Created:
                case JobStatus.Running:
                    var timestamp = DateTime.UtcNow;

                    DateTime scheduledTime = timestamp + _checkInterval;

                    var supervise = new Supervise(context.Message.JobId, timestamp, JobStatus.Running);

                    context.ScheduleSend(scheduledTime, supervise);

                    if (_log.IsDebugEnabled)
                    {
                        _log.DebugFormat("Scheduled next supervise message: {0}", context.Message.JobId);
                    }
                    break;

                case JobStatus.RanToCompletion:
                    _roster.RemoveJob(context.Message.JobId);
                    break;

                case JobStatus.Faulted:
                    _roster.RemoveJob(context.Message.JobId);
                    break;

                case JobStatus.Canceled:
                    _roster.RemoveJob(context.Message.JobId);
                    break;
                }
            }
            else
            {
                if (_log.IsWarnEnabled)
                {
                    _log.WarnFormat("JobId not found: {0}", context.Message.JobId);
                }
            }

            return(TaskUtil.Completed);
        }
        async Task <JobHandle <T> > ITurnoutController.CreateJob <T>(ConsumeContext <T> context, IJobFactory <T> jobFactory)
        {
            var jobContext = new ConsumerJobContext <T>(context);

            var babyTask = Run(jobContext, jobFactory);

            var jobHandle = new ConsumerJobHandle <T>(jobContext, babyTask);

            _roster.Add(jobContext.JobId, jobHandle);

            var utcNow        = DateTime.UtcNow;
            var scheduledTime = utcNow + _superviseInterval;

            var check = new Supervise(jobContext.JobId, utcNow, jobHandle.Status);

            await context.ScheduleMessage(_controlAddress, scheduledTime, check).ConfigureAwait(false);

            return(jobHandle);
        }