Parse Job Scheduling - parse-platform

I have a problem with the parse job scheduler. I have made a job that accepts some parameters and I want to run different instances of this job. Is there a way to do this? When I click on the Schedule a Job button it doesn't recognize a job that second time. It only lets me create the first job. And also in the new parse dashboard the schedule a job button is not even there.

As a free users you can only schedule one single job. If you want to schedule more than one job you must pay for it. Take a look here for more information.

Related

Identify a spring-batch job instance with incrementer

let me discribe shortly what I want and what I - maybe - know.
I want spring-batch to run a async job; in future more jobs.
The job gets two parameters: an external id and a year.
The job should be able to be restarted after completion because the user wants to run a job with the same parameters again and again.
Only one job should be executed with the same parameters at the same time.
From outside (web interface) it should be possible to query if a job is running by job name and parameters.
The querier could be different from the job starter so an instance or execution id is not present.
I know that a job instance is the representation of the job(name) and the parameters and - like you commented - I cannot rerun a job with the same parameters if the instance/execution is marked completed - except I use a incrementer.
But this changes the parameters by adding a run.id. Now a job is restartable but I and sping-batch itself are not able to identify a running job instance (by name and original parameters) anymore because every job run results in a new instance.
And the question "why would one would restart a successfully completed job instance?" is easy to answer: The user outside don't know about job/instance/execution. The user will start some data processing for a year again and again. And it's my task to make it possible :).
So it would be nice if spring-batch can let the user know "the job with your original parameters is still running".
Question:
What would be a good solution for my needs?
I didn't tried something but thought about it. Maybe I can write an own JobDao for my query? But this will not solve the run-instance-at-same-time problem. Or I can customize the JdbcJobInstanceDao or SimpleJobRepository? Maybe I must add a own job_key which contains only the original parameters?
To correctly understand the answer I am going to give to your question, it is important to know the difference and understand the relation between a job, a job instance and a job execution in Spring Batch. The The Domain Language of Batch section of the reference documentation explains that in details with examples.
The job should be able to be restarted after completion.
This is not possible by design, or more precisely, a job instance cannot be restarted after completion by design (Think of it like "why would one would restart a successfully completed job instance?").
From outside (web interface) it should be possible to query if an instance is running by job name and parameters. There querier could be different from the job starter so an instance or execution id is not present.
The JobExplorer is the API you are looking for. You can ask for job instances and job executions as needed.
Question: What would be a good solution for my needs?
In your case, you receive an external ID and a year as a job execution request. Those two parameters can be used as identifying parameters to define job instances. With this in place, if a job instance is failed, you can restart it by using the same parameters.
I see no need for an incrementer in your case. The incrementer is useful for jobs for which the instances can be defined as a "sequence" that can be "incremented". I see no need to create a custom DAO or JobRepository neither, you should be able to implement your requirement with the built-in components by correctly defining what a job instance is.
For my use-case I have to check if a execution for a job/parameters-combination is running. The parameters here are without run.id of an incrementor. This check must be done before a job run and by explicit rest call. Normally spring-batch checks for running executions but because of the used incrementor every job instance is unique and it will never find any.
So I created a bean with a check method and made use of jobExplorer.findRunningJobExecutions(jobName);. The result can then compared with the used paramters by iterating over JobExecution.getJobParameters().getParameters().
The bean can be used in the rest-method and in an own implemention of JobLauncher.run().
Another solution would be to store the increment separately for a job/parameters-combination. But I don't want to do this not least because I think a framework like spring-batch should do this for me or supports me by reusing/restarting a completed job instance.

Use gocron scheduler to schedule job on specific day at specific time

I want to schedule a job on a specific day at a specific time with some interval. I am using gocron scheduler for this. But I can't find a way to start a job on specific day. e.g. I want to execute a job on 7 Sept 2019 at 330pm. From 7 Sept, I want that job to be executed daily or weekly. How can I do that using gocron. or Any other packages available?
I tried passing UTC time to gocron.At() but its panics as it's expecting only "03:30" time formats and doesn't expect date.
When looking at the documentation for gocron, it does not seem to be designed to support scheduling things for specific days. It seems to be designed as a way to schedule things to run at various intervals, very similar to what the original cron utility was designed to do. So you would specify "I want this function to get called every 2 hours" or "I want this function to get called every Sunday at 3PM". There does not seem to be any documentation about starting jobs from a specific day.
The mentioned At(string) method is documented as allowing you to specify a time of day to run something. So you would use that to set that your job runs at 3:30PM.
If you wish to specify a start time, you would likely need to find another scheduling library or implement it yourself by creating a goroutine that sleeps until a specific time. The StackOverflow post mentioned by domcyrus looks like an excellent resource for implementing it yourself as well as listing some other scheduling libraries.

Scheduling a job multiple times

I wrote a background job that accepts some parameters, and I scheduled it to run periodically. I now want to schedule it with a different parameter set, but the parse.com console says I have no background jobs.
I've worked around the problem adding the same job multiple times with slightly different names, but this solution is far from ideal. There should be a way to schedule a job with multiple parameter set and different schedules.
Is there a way to schedule the same job multiple times?

how do I share or store the state of previous MapReduce job for the next job?

I would like to store/alter a flag (this will change occasionally) at the end of a mapreduce job. This job will be schedule to run every 30 mins. So at first it will store the flag and then when a validation fails in the job it will alter the flag (I would like to keep this state for the next job), which will be checked at each execution of the job. I'm not too sure what is the best way to store this flag?
To chain MapReduce jobs check this out: https://developer.yahoo.com/hadoop/tutorial/module4.html#chaining
However, if you require the jobs to run every x mins, try Oozie for scheduling them. If you are on AWS check out DataPipeline, it does exactly what you want.

Ruby on Rails: Delayed Job is it possible to execute one job then stop?

I want to only send out one email at a time so I have a script starting every minute. Is it possible to only send out one email and then stop the delayed job from sending the next queued jobs?
Before you place the next job on the queue, you could look at the last job that's already on the queue, and check it's run_at time. Then set the run_at time for your job to be one minute later. If there's no jobs on the queue, set it to now, or one minute from now, depending on how strict you need to be about one minute between.
You could fetch one specific job from DJ's table itself, invoke it and then destroy it, something like:
job = Delayed::Job.last
job.invoke_job # This will NOT destroy the job
job.destroy
Found it here: https://groups.google.com/forum/#!topic/delayed_job/5j5BmAlXN3g

Resources