예제 #1
0
 public void Add(AgentRecord r)
 {
     lock (_lock)
     {
         _agentData[r.Id] = r;
     }
 }
예제 #2
0
 public void Add(AgentRecord r)
 {
     lock (agentData)
     {
         agentData[r.Id] = r;
     }
 }
예제 #3
0
        //public override void Stop()
        //{
        //    foreach( KeyValuePair<Guid,AgentRecord> pair in agentData )
        //    {
        //        AgentRecord r = pair.Value;

        //        if ( !r.Process.HasExited )
        //        {
        //            if ( r.Agent != null )
        //            {
        //                r.Agent.Stop();
        //                r.Process.WaitForExit(10000);
        //            }

        //            if ( !r.Process.HasExited )
        //                r.Process.Kill();
        //        }
        //    }

        //    agentData.Clear();

        //    base.Stop ();
        //}
        #endregion

        #region Public Methods - Called by Agents
        public void Register(ITestAgent agent)
        {
            AgentRecord r = _agentData[agent.Id];

            if (r == null)
            {
                throw new ArgumentException(
                          string.Format("Agent {0} is not in the agency database", agent.Id),
                          "agentId");
            }
            r.Agent = agent;
        }
예제 #4
0
        public void AddAgent(Guid agentId, Process process)
        {
            lock (_agentsById)
            {
                if (_agentsById.ContainsKey(agentId))
                {
                    throw new ArgumentException($"An agent has already been started with the ID '{agentId}'.", nameof(agentId));
                }

                _agentsById.Add(agentId, AgentRecord.Starting(process));
            }
        }
예제 #5
0
        public void ReportStatus(Guid agentId, AgentStatus status)
        {
            AgentRecord r = _agentData[agentId];

            if (r == null)
            {
                throw new ArgumentException(
                          string.Format("Agent {0} is not in the agency database", agentId),
                          "agentId");
            }

            r.Status = status;
        }
예제 #6
0
        public void ReleaseAgent(ITestAgent agent)
        {
            AgentRecord r = _agentData[agent.Id];

            if (r == null)
            {
                log.Error(string.Format("Unable to release agent {0} - not in database", agent.Id));
            }
            else
            {
                r.Status = AgentStatus.Ready;
                log.Debug("Releasing agent " + agent.Id.ToString());
            }
        }
예제 #7
0
            public AgentRecord this[ITestAgent agent]
            {
                get
                {
                    foreach (KeyValuePair <Guid, AgentRecord> entry in agentData)
                    {
                        AgentRecord r = entry.Value;
                        if (r.Agent == agent)
                        {
                            return(r);
                        }
                    }

                    return(null);
                }
            }