예제 #1
0
파일: AgentsEngine.cs 프로젝트: Kidify/L4p
 void IAgentsEngine.warn_inactive_agents(AgentInfo[] agents)
 {
     foreach (var agent in agents)
     {
         _log.Trace("Agent is inactive; {0}", agent.AsSingleLineJson());
     }
 }
예제 #2
0
파일: AgentsEngine.cs 프로젝트: Kidify/L4p
        void IAgentsEngine.send_goodbye_msgs(AgentInfo[] agents, string goodbyeAgent)
        {
            foreach (var agent in agents)
            {
                if (agent.AgentUri == goodbyeAgent)
                    continue;

                _messenger.SendGoodbyeMsg(agent.AgentUri, goodbyeAgent);
            }
        }
예제 #3
0
파일: AgentsEngine.cs 프로젝트: Kidify/L4p
        AgentInfo[] IAgentsEngine.send_hello_msgs(AgentInfo[] agents, AgentInfo helloAgent, int snapshotId)
        {
            var cleanAgents = new List<AgentInfo>();
            cleanAgents.Add(helloAgent);

            foreach (var agent in agents)
            {
                if (agent.ClearAgentsListIsCompleted == 0)
                    continue;

                bool sent = _messenger.SendHelloMsg(agent.AgentUri, helloAgent.AgentUri, snapshotId);

                if (sent)
                    cleanAgents.Add(agent);
            }

            return
                cleanAgents.ToArray();
        }
예제 #4
0
파일: HubRepo.cs 프로젝트: Kidify/L4p
 void IHubRepo.SetConsequentSnapshotId(AgentInfo agent, int snapshotId, DateTime now)
 {
     lock (_mutex) _impl.SetConsequentSnapshotId(agent, snapshotId, now);
 }
예제 #5
0
파일: HubRepo.cs 프로젝트: Kidify/L4p
 void IHubRepo.AgentsAreUpdated(AgentInfo refAgent, AgentInfo[] cleanAgents, int snapshotId)
 {
     lock (_mutex) _impl.AgentsAreUpdated(refAgent, cleanAgents, snapshotId);
 }
예제 #6
0
파일: HubRepo.cs 프로젝트: Kidify/L4p
 AgentInfo[] IHubRepo.QueryDirtyAgents(AgentInfo refAgent, int snapshotId)
 {
     lock (_mutex) return _impl.QueryDirtyAgents(refAgent, snapshotId);
 }
예제 #7
0
파일: HubRepo.cs 프로젝트: Kidify/L4p
        private List<string> get_agent_state(AgentInfo agent)
        {
            List<string> list;

            _state.TryGetValue(agent.AgentUri, out list);

            if (list != null)
                return list;

            list = new List<string>();
            _state[agent.AgentUri] = list;

            return list;
        }
예제 #8
0
파일: HubRepo.cs 프로젝트: Kidify/L4p
        private AgentInfo new_agent_info(string agentUri)
        {
            var agent = new AgentInfo
                {
                    AgentUri = agentUri,
                    SnapshotId = 0
                };

            _agents.Add(agentUri, agent);
            _state[agentUri] = null;

            return agent;
        }
예제 #9
0
파일: HubRepo.cs 프로젝트: Kidify/L4p
        void IHubRepo.SetConsequentSnapshotId(AgentInfo agent, int snapshotId, DateTime now)
        {
            Validate.NotNull(agent);

            agent.LastUpdateAt = now;

            if (agent.SnapshotId >= snapshotId)
                return;

            agent.SnapshotId = snapshotId;
            _state[agent.AgentUri] = null;
        }
예제 #10
0
파일: HubRepo.cs 프로젝트: Kidify/L4p
        AgentInfo[] IHubRepo.QueryDirtyAgents(AgentInfo refAgent, int snapshotId)
        {
            var allAgents = _agents.Values.ToArray();
            var cleanAgents = get_agent_state(refAgent);

            Validate.NotNull(cleanAgents);

            var query =
                from agent in allAgents
                where !cleanAgents.Contains(agent.AgentUri)
                select agent;

            var dirtyAgents = query.ToArray();
            return dirtyAgents;
        }
예제 #11
0
파일: HubRepo.cs 프로젝트: Kidify/L4p
        void IHubRepo.AgentsAreUpdated(AgentInfo refAgent, AgentInfo[] cleanAgents, int snapshotId)
        {
            if (refAgent.SnapshotId > snapshotId)
                return;

            var list = get_agent_state(refAgent);

            foreach (var agent in cleanAgents)
            {
                add_clean_agent_to_state(list, agent.AgentUri);
            }
        }
예제 #12
0
파일: SignalsHub.cs 프로젝트: Kidify/L4p
 private void remove_dead_agents(AgentInfo[] agents, TimeSpan deadAgentTtl)
 {
     foreach (var agent in agents)
     {
         _log.Info("Agent at '{0}' is dead (ttl='{1}'; sending goodbye message)", agent.AgentUri, deadAgentTtl);
         agent_is_gone(agent.AgentUri);
     }
 }
예제 #13
0
파일: SignalsHub.cs 프로젝트: Kidify/L4p
        private void clear_remote_agents_on_first_hello(AgentInfo agent)
        {
            if (Interlocked.CompareExchange(ref agent.ClearAgentsListIsSent, 1, 0) > 0)
                return;

            Interlocked.Increment(ref _counters.NewAgents);
            _messenger.ClearAgentsList(agent.AgentUri);

            agent.ClearAgentsListIsCompleted = 1;
        }