コード例 #1
0
 /// <summary>
 /// Build command in xml presentation.
 /// </summary>
 /// <param name="command">Command.</param>
 /// <param name="guid">Guid.</param>
 /// <param name="result">Result.</param>
 /// <returns>XML message.</returns>
 protected string BuildXmlCommand(string command, string guid, string result)
 {
     ControlMessage cm = new ControlMessage(command, guid, result);
     return cm.ToXml(SelfInfo);
 }
コード例 #2
0
        /// <summary>
        /// Unblock node.
        /// </summary>
        /// <param name="id">Node id.</param>
        public void UnblockNode(string id)
        {
            lock (_blockNodes)
            {
                if (!_blockNodes.ContainsKey(id))
                {
                    return;
                }

                ControlMessage cm = new ControlMessage(CommandType.Unblock.ToString(), "null", string.Empty);
                string message = cm.ToXml(_blockNodes[id]);
                SendToAll(message);
            }
        }
コード例 #3
0
        /// <summary>
        /// Set working status.
        /// </summary>
        /// <param name="id">Node id.</param>
        /// <param name="status">Busy status.</param>
        public void SetWorkingStatus(string id, bool status)
        {
            lock (_correspondingNodes)
            {
                CommandType command = status ? CommandType.StartWork : CommandType.StopWork;
                if (_correspondingNodes.ContainsKey(id))
                {
                    NodeInfo ni = _correspondingNodes[id];

                    ControlMessage cm = new ControlMessage(command.ToString(), "null", string.Empty);
                    string message = cm.ToXml(ni);
                    SendUdpMessage(message, ni.IP, ni.Port);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Block node.
        /// </summary>
        /// <param name="id">Node id.</param>
        public void BlockNode(string id)
        {
            lock (_correspondingNodes)
            {
                if (!_correspondingNodes.ContainsKey(id))
                {
                    return;
                }

                ControlMessage cm = new ControlMessage(CommandType.Block.ToString(), "null", string.Empty);
                string message = cm.ToXml(_correspondingNodes[id]);
                SendToAll(message);
            }

            lock (_schedulingJobs)
            {
                foreach (Job job in _schedulingJobs.Values)
                {
                    if (job.RunningNode != null && job.RunningNode.Id == id)
                    {
                        // reschedule this job
                        job.Status = JobStatus.Nonscheduled;
                        Console.WriteLine("{0} Job {1}, which runs on removed node {2}, is recheduled.",
                            DateTime.Now.ToShortTimeString(), job.Name, id);
                    }
                }
            }
        }