コード例 #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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: Prelude.cs プロジェクト: tanxeel90/echo-process
        /// <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)));
        }
コード例 #4
0
ファイル: Prelude.cs プロジェクト: tanxeel90/echo-process
        /// <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)));
        }
コード例 #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);
        }
コード例 #6
0
 internal IActorDispatch GetLocalDispatcher(ProcessId pid) =>
 pid.Take(2) == RootJS
         ? GetJsDispatcher(pid)
         : GetDispatcher(pid.Tail(), rootItem, pid);
コード例 #7
0
ファイル: Role.cs プロジェクト: tanxeel90/echo-process
 public static HashMap <ProcessName, ClusterNode> Nodes(ProcessId leaf, SystemName system = default(SystemName)) =>
 ClusterNodes(system).Filter(node => node.Role == leaf.Take(1).Name);