public CommandResponse Handle(CommandRequest request)
        {
            if (string.IsNullOrEmpty(request.Target))
            {
                return(CommandResponse.Create(false));
            }
            var groupName = new StitchGroupName(request.Target);

            var job = _jobManager.CreateJob("Command=" + request.Command);

            var stitches = _data.GetStitchesInGroup(groupName);

            foreach (var stitch in stitches)
            {
                var subtask = job.CreateSubtask(CommandType, stitch.Id, _nodeId);
                if (stitch.NodeId == _nodeId)
                {
                    SendLocal(job, subtask, stitch);
                }
                else
                {
                    SendRemote(job, subtask, stitch);
                }
            }

            // Save the job to get an Id
            _jobManager.Save(job);
            return(CommandResponse.Started(job.Id));
        }
Пример #2
0
        private CommandResponse HandleRemote(CommandRequest request, StitchSummary stitch)
        {
            string nodeId = stitch.NodeId;
            var    node   = _data.Get <NodeStatus>(nodeId);

            if (node == null)
            {
                return(CommandResponse.Create(false));
            }

            // Create a job to track status
            var job     = _jobManager.CreateJob("Command=" + request.Command);
            var subtask = job.CreateSubtask(request.Command, request.Target, stitch.NodeId);

            // Create the message and send it over the backplane
            _sender.SendCommandRequest(node.NetworkNodeId, request, job, subtask);

            _jobManager.Save(job);

            return(CommandResponse.Started(job.Id));
        }
Пример #3
0
        public CommandResponse Handle(CommandRequest request)
        {
            string nodeId = request.Target;

            if (nodeId == _nodeId)
            {
                return(CommandResponse.Create(true));
            }
            var node = _data.Get <NodeStatus>(nodeId);

            if (node == null)
            {
                return(CommandResponse.Create(false));
            }

            var job     = _jobManager.CreateJob("Command=Ping");
            var subtask = job.CreateSubtask(request.Command, request.Target, nodeId);

            // Create the message and send it over the backplane
            _sender.SendCommandRequest(node.NetworkNodeId, request, job, subtask);
            _jobManager.Save(job);
            return(CommandResponse.Started(job.Id));
        }