コード例 #1
0
ファイル: Daemon.cs プロジェクト: jyyconrad/gearman.net
        private void handleJobSubmitted(Packet p, JobPriority priority, bool background)
        {
            Guid   jobid     = Guid.NewGuid();
            string jobhandle = String.Format("{0}:{1}", hostName, jobid);

            SubmitJob sj = (SubmitJob)p;

            var job = new Job()
            {
                TaskName   = sj.taskname,
                JobHandle  = jobhandle,
                Unique     = sj.unique_id,
                When       = sj.when,
                Priority   = (int)priority,
                Data       = sj.data,
                Dispatched = false,
            };

            bool success = queue.storeJob(job, true);

            Console.WriteLine("{0} == {1}", job.JobHandle, job.Id);
            GearmanServer.Log.Info("Job was submitted!");
            conn.sendPacket(new JobCreated(jobhandle));

            if (sj.when <= DateTime.UtcNow && workers.ContainsKey(sj.taskname))
            {
                foreach (Gearman.Connection c in workers[sj.taskname])
                {
                    c.sendPacket(new NoOp());
                }
            }
        }
コード例 #2
0
        public ActionResult DeleteSubmitJob(int?id, int?idcv)
        {
            SubmitJob submitJob = db.SubmitJobs.Find(id);

            db.SubmitJobs.Remove(submitJob);
            db.SaveChanges();
            return(Redirect("/Employer/CvsEmployer/DetailsCvs?id=" + idcv));
        }
コード例 #3
0
 /// <summary>
 /// Bundles up the user's settings and sends the data to the presenter to submit the job.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void OnOKClicked(object sender, EventArgs e)
 {
     try
     {
         await SubmitJob?.Invoke(this, EventArgs.Empty);
     }
     catch (Exception err)
     {
         ShowError(err);
     }
 }
コード例 #4
0
ファイル: Client.cs プロジェクト: jyyconrad/gearman.net
        /// <summary>
        /// Submit a job to a job server for processing. The callback string is used as the
        /// task for the manager to hand off the job to a worker.
        /// </summary>
        /// <param name="callback">
        /// A string containing the name of the operation to ask the manager to find a worker for
        /// </param>
        /// <param name="data">
        /// A byte array containing the data to be worked on. This data is passed to the worker who can
        /// work on a job of the requested type.
        /// </param>
        /// <returns>
        /// A byte array containing the response from the worker that completed the task
        /// </returns>
        /// <example>
        ///  <code>
        ///   Client c = new Client("localhost");
        ///   byte[] data = new ASCIIEncoding().GetBytes("foo\nbar\nquiddle\n");
        ///   byte[] result = c.submitJob("wc", data);
        ///  </code>
        /// </example>
        public byte[] submitJob(string callback, byte[] data)
        {
            try {
                Packet     result    = null;
                bool       submitted = false;
                Connection c         = null;

                string jobid = System.Guid.NewGuid().ToString();

                SubmitJob p = new SubmitJob(callback, jobid, data, false);

                while (!submitted)
                {
                    // Simple round-robin submission for now
                    c = managers[connectionIndex++ % managers.Count];

                    c.sendPacket(p);

                    Log.DebugFormat("Sent job request to {0}...", c);

                    // We need to get back a JOB_CREATED packet
                    result = c.getNextPacket();

                    // If we get back a JOB_CREATED packet, we can continue
                    // otherwise try the next job manager
                    if (result.Type == PacketType.JOB_CREATED)
                    {
                        submitted = true;
                        Log.DebugFormat("Created job {0}", ((JobCreated)result).jobhandle);
                    }
                }


                // This method handles synchronous requests, so we wait
                // until we get a work complete packet
                while (true)
                {
                    result = c.getNextPacket();

                    if (result.Type == PacketType.WORK_COMPLETE)
                    {
                        WorkComplete wc = (WorkComplete)result;

                        Log.DebugFormat("Completed job {0}", wc.jobhandle);
                        return(wc.data);
                    }
                }
            } catch (Exception e) {
                Log.DebugFormat("Error submitting job: {0}", e.ToString());
                return(null);
            }
        }
コード例 #5
0
        public ActionResult SubmitJob(SubmitJob submitJob, int?id)
        {
            var cookie = new FunctionController();
            var idus   = cookie.CookieIDEm();

            submitJob.user_id       = idus.user_id;
            submitJob.sj_datecreate = DateTime.Now;
            submitJob.cv_id         = id;


            db.SubmitJobs.Add(submitJob);
            db.SaveChanges();
            return(Redirect("/Employer/CvsEmployer/DetailsCvs?id=" + id));
        }
コード例 #6
0
ファイル: Client.cs プロジェクト: jyyconrad/gearman.net
        /// <summary>Submit a job to the job server in the background, with a particular priority</summary>
        /// <example>
        /// <code>
        /// </code>
        /// </example>
        public string submitJobInBackground(string callback, byte[] data, JobPriority priority)
        {
            try {
                Connection c = null;

                string jobid = System.Guid.NewGuid().ToString();

                SubmitJob p = new SubmitJob(callback, jobid, data, true, priority);

                Packet result;

                while (true)
                {
                    // Simple round-robin submission for now
                    c = managers[connectionIndex++ % managers.Count];

                    c.sendPacket(p);

                    Log.DebugFormat("Sent background job request to {0}...", c);

                    // We need to get back a JOB_CREATED packet
                    result = c.getNextPacket();

                    // If we get back a JOB_CREATED packet, we can continue,
                    // otherwise try the next job manager
                    if (result.Type == PacketType.JOB_CREATED)
                    {
                        Log.DebugFormat("Created background job {0}, with priority {1}", ((JobCreated)result).jobhandle, priority.ToString());
                        return(((JobCreated)result).jobhandle);
                    }
                }
            } catch (Exception e) {
                Log.DebugFormat("Error submitting job: {0}", e.ToString());
                return(null);
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: afowles/MS-Project
        /// <summary>
        /// Main method, run with --help for details
        /// </summary>
        /// <param name="args">program arguments</param>
        public static void Main(string[] args)
        {
            var commandLineApp = new CommandLineApplication(false)
            {
                Name = "defcore"
            };

            // Set up the command for running the server
            commandLineApp.Command("server", c =>
            {
                c.HelpOption("-?|-h|--help");
                c.Description = "Runs the NodeManager server on a local IP address";
                // specifiy and option
                var directoryOption = c.Option("-d|--directory <PATH>",
                                               "Path to the working directory of the server, input will be relative to current directory", CommandOptionType.SingleValue);
                c.OnExecute(() =>
                {
                    if (directoryOption.HasValue())
                    {
                        SetOrCreateWorkingDirectory(directoryOption.Value());
                    }
                    NodeManager.Main();
                    return(0);
                }
                            );
            });
            // set up a command for running the node
            commandLineApp.Command("node", c =>
            {
                c.HelpOption("-?|-h|--help");
                c.Description = "Runs the Node on a local IP address";

                // specifiy and option
                var directoryOption = c.Option("-d|--directory <PATH>",
                                               "Path to the working directory of the node, input will be relative to current directory", CommandOptionType.SingleValue);
                var ipArgument = c.Argument("[IP]", "The IP address for the server");
                c.OnExecute(() =>
                {
                    if (directoryOption.HasValue())
                    {
                        SetOrCreateWorkingDirectory(directoryOption.Value());
                    }
                    if (ipArgument.Values.Count == 0)
                    {
                        Console.WriteLine("Must provide an ip address, use --help for more details");
                        return(1);
                    }
                    Node.Main(new [] { ipArgument.Value });
                    return(0);
                });
            });

            // set up a command for submitting a job
            commandLineApp.Command("submit", c =>
            {
                c.HelpOption("-?|-h|--help");
                c.Description = "submits a job to the system";

                // specifiy and option
                var directoryOption = c.Option("-d|--directory <PATH>",
                                               "Path to the working directory, input will be relative to current directory", CommandOptionType.SingleValue);
                //var ipArgument = c.Argument("[IP]", "The IP address for the server");
                var program = c.Argument("program", "User program and arguments", true);
                c.OnExecute(() =>
                {
                    if (directoryOption.HasValue())
                    {
                        SetOrCreateWorkingDirectory(directoryOption.Value());
                    }
                    SubmitJob.Main(program.Values.ToArray());
                    return(0);
                });
            });

            // setup a command for loading an executable
            commandLineApp.Command("load", c =>
            {
                c.HelpOption("-?|-h|--help");
                c.Description = "loads a job to and executes it";

                var program = c.Argument("arguments", "program arguments", true);
                c.OnExecute(() =>
                {
                    JobExecuter.Main(program.Values.ToArray());
                    return(0);
                });
            });

            commandLineApp.HelpOption("-? | -h | --help");
            commandLineApp.OnExecute(() =>
            {
                if (args.Length == 0)
                {
                    Console.WriteLine(commandLineApp.GetHelpText());
                }
                return(0);
            });

            try
            {
                commandLineApp.Execute(args);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }