Example #1
0
        Option <ActorItem> GetLocalActor(ActorItem current, ProcessId walk, ProcessId pid)
        {
            if (current.Actor.Id == pid)
            {
                return(current);
            }
            var name = walk.Take(1).Name;

            return(from child in current.Actor.Children.Find(walk.Take(1).Name.Value)
                   from result in GetLocalActor(child, walk.Skip(1), pid)
                   select result);
        }
        Unit DoScheduleNoIO(object message, ProcessId sender, Schedule schedule, Message.Type type, Message.TagSpec tag)
        {
            var inboxKey = ActorInboxCommon.ClusterScheduleKey(ProcessId);
            var id       = schedule.Key ?? Guid.NewGuid().ToString();
            var current  = Cluster.GetHashField <RemoteMessageDTO>(inboxKey, id);

            message = current.Match(
                Some: last =>
            {
                var a = MessageSerialiser.DeserialiseMsg(last, ProcessId) as UserMessage;
                var m = a == null
                        ? message
                        : schedule.Fold(a.Content, message);
                return(m);
            },
                None: () => schedule.Fold(schedule.Zero, message));

            ValidateMessageType(message, sender);

            var dto = RemoteMessageDTO.Create(message, ProcessId, sender, type, tag, SessionId, schedule.Due.Ticks);

            tell(ProcessId.Take(1).Child("system").Child("scheduler"), Scheduler.Msg.AddToSchedule(inboxKey, id, dto));

            //Cluster.HashFieldAddOrUpdate(inboxKey, id, dto);
            return(unit);
        }
Example #3
0
        /// <summary>
        /// Cancel an already scheduled message
        /// </summary>
        public static Unit cancelScheduled(ProcessId pid, string key)
        {
            var inboxKey = ActorInboxCommon.ClusterScheduleKey(pid);

            LocalScheduler.RemoveExistingScheduledMessage(pid, key);
            return(tell(pid.Take(1).Child("system").Child("scheduler"), Scheduler.Msg.RemoveFromSchedule(inboxKey, key)));
        }
Example #4
0
        /// <summary>
        /// Re-schedule an already scheduled message
        /// </summary>
        public static Unit reschedule(ProcessId pid, string key, DateTime when)
        {
            var inboxKey = ActorInboxCommon.ClusterScheduleKey(pid);

            LocalScheduler.Reschedule(pid, key, when);
            return(tell(pid.Take(1).Child("system").Child("scheduler"), Scheduler.Msg.Reschedule(inboxKey, key, when)));
        }
Example #5
0
        public Unit DeregisterById(ProcessId pid)
        {
            if (!pid.IsValid)
            {
                throw new InvalidProcessIdException();
            }
            if (pid.Take(2) == Disp["reg"])
            {
                throw new InvalidProcessIdException(@"
When de-registering a Process, you should use its actual ProcessId, not its registered
ProcessId.  Multiple Processes can be registered with the same name, and therefore share
the same registered ProcessId.  The de-register system can only know for sure which Process
to de-register if you pass in the actual ProcessId.  If you want to deregister all Processes
by name then use Process.deregisterByName(name).");
            }

            Cluster.Match(
                Some: c =>
            {
                if (IsLocal(pid) && GetDispatcher(pid).IsLocal)
                {
                    RemoveLocalRegisteredById(pid);
                }
                else
                {
                    var path    = pid.Path;
                    var regpath = path + "-registered";

                    // TODO - Make this transactional
                    // {
                    var names = c.GetSet <string>(regpath);
                    names.Iter(name =>
                    {
                        c.SetRemove(ProcessId.Top["__registered"][name].Path, path);
                    });
                    c.Delete(regpath);
                    // }
                }
            },
                None: () =>
            {
                RemoveLocalRegisteredById(pid);
            }
                );
            return(unit);
        }
Example #6
0
 internal IActorDispatch GetLocalDispatcher(ProcessId pid) =>
 pid.Take(2) == RootJS
         ? GetJsDispatcher(pid)
         : GetDispatcher(pid.Tail(), rootItem, pid);
Example #7
0
 public static HashMap <ProcessName, ClusterNode> Nodes(ProcessId leaf, SystemName system = default(SystemName)) =>
 ClusterNodes(system).Filter(node => node.Role == leaf.Take(1).Name);