Recurrent job in an Eclipse plugin - eclipse

Using the Eclipse Job class, it is possible to schedule a job to run certain amount of time after it is scheduled, like this:
Job job = getMyJob();
job.schedule(delayInMilliseconds);
This will run the job after the specified delay, is there a way to create a job that runs at a given hour of the day, everyday?, for example, I want to run a job at 5pm, everyday, so if Eclipse happens to be open at 5pm the job will run, if it is closed, then the job will be skipped that day and it will wait for the next day.
Is there a way to create this type of recurrent job?

No, the Job API doesn't have anything like this.
You could use something like the scheduleAtFixedRate method of ScheduledExecutorService to schedule a Runnable to submit the job once a day.

Related

What is a good use case for a delay task in Uber Cadence?

I want to implement a delay task and found a cadence cron example, how to use cadence to implement a delay task?
Cron is for periodic execution of some functionality.
If you need to delay a task you can call sleep and the beginning of the workflow and then call an activity that executes the task.
Cadence supports both activity and workflow delaying.
Activity delay can be achieved with Workflow.Sleep API
Workflow delay can be achieved with DelayStart option. See https://github.com/uber-go/cadence-client/blob/e66e2d4da8def80e7a5730b824a2de7a28f5c050/internal/client.go#L415
For regular workflows, this will delay execution that many seconds, then start.
For cron workflows, this will delay ONLY the FIRST execution. For example you want to set up an hourly cron workflow but you want it to start running from next week on Monday at 9AM. You can pass delayStart seconds option to delay till that Monday between 8AM and 9AM so it will start at 9AM since it's the next schedule.

How to create a Teamcity build trigger that will run job B once per week, after job A finished, where A runs daily

I have some Teamcity jobs created.
One of those jobs, let's call it job A, has a schedule trigger, running daily at 7:00 am.
Now I have another one, job B, that I want to run once per week, but only after job A ran.
Given that job A takes about 30 seconds to run, I know I can create a schedule trigger for job B, that will run on every Monday, at 07:10 am.
I also know I can create a Finish Build Trigger, making sure that job B runs after job A ran, but it will run every day(because job A needs to run every day)
I'm trying to find a way to combine these, and come up with some sort of trigger that does something like this:
runs job B once per week(say Monday morning), after job A ran.
Could someone nudge me in the right direction? Or explain to me if/why what I'd like to do is a no-no. Thanks
It looks like the feature called Snapshot Dependency fits well into your scenario.
To tell it short, you can link the two jobs you have with the snapshot dependency. In your case, job B will "snapshot-depend" on job A. In my experience, it works best if both jobs use the same VCS root, that is, work with the same repository.
Job A is configured to run daily and job B is configured to run weekly (via regular scheduled triggers). When job A is triggered, it doesn't affect job B at all. On the other hand, when job B is triggered, it tries to find whether there's a suitable build of A by that time. If the two jobs work with the same repo, and the Enforce revision synchronization flag is ON, this means it will try to find the build of A of that same source code revision.
If there's a suitable build of A, it won't trigger a new one and will just build B. If there's no suitable build of A, it will first trigger A, and then trigger the build of B.

Quartz: Undesired multiple job run in same time

I have some jobs that run with their schedule, but when I have for example two jobs that run in same time Quartz start one of this jobs two or three times. Did someone have the same problem? And how can I resolve this?
I am not entirely sure, but there could be copule reasons,
1). you are creating a new scheduler instance everytime you trigger/schedule job
2). or you are running the same exact Execute method of a class or have same job running eveytime.
So, when you declare your scheduler, instead of working on some other instance of scheduler, use default scheduler all time, for e.g.,
private IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
that is what I have done and I have a lot notifications/jobs triggering using Quartz.Net and haven't faced any issue yet.
Let me know if any of this helps. Cheers!

Setting up a Job Schedule

I currently have a setup that creates a job and then collect some metrics about the tasks in the job. I want to do something similar, but by setting a job schedule instead. In particular, I want to set a job schedule that wakes up at a recurrence interval that I specify, and run the same code that I was running when creating a job. What's the best way to go about doing that?
It seems that there is a CloudJobSchedule that I could use to set up my job schedule, but this only lets me create say a job manager task, and specify few properties. How can I run external code on the jobs created by the Job schedule?
It could also help to clarify how the CloudJobSchedule works. Specifically, after I commit my job schedule, what would happen programmatically. Does the code just move sequentially and run the rest of the code. In this case, does it make sense to get a reference to the last job created by the job schedule and run code on the job returned?
You'll want to create a CloudJobSchedule. You can specify the recurrence in the Schedule.
If you only need to run a single task per recurrence, your job manager task can simply be the task you need to run. If you need to run multiple tasks per job recurrence, your job manager needs to have logic to submit tasks to Batch and monitor for completion (if necessary).
When you submit a job schedule to Batch, your client side code will continue running. The behavior is no different than if you were submitting a regular job. You can retrieve the last job run via JobScheduleExecutionInformation and the RecentJob property.

Run scheduler to execute jobs at an interval from the completion of the previous job

I need to create schedulers to execute jobs(class files) at specified intervals..For Now, I'm using Quartz Scheduler which triggers the jobs at defined intervals from the time of triggering of it.
For Eg: Consider I'm giving a cron expression to run for every one hour starting at morning 9.My first run will be at 9 and my second run will be at 10 and so on.
If my job is taking 20 minutes to execute then in that case this method is not that much efficient.
What I need to do is to schedule a job for every one hour from the completion time of the previously ran job
For Eg: Consider my job to run every one hour is triggered at 9 and for the first run it took 20 minutes to run, so for the next time the job should trigger only at 10:20 instead of 10 (ie., one hour from the completion of previous ran job)
I need to know whether there are any methods in Quartz Scheduling to achieve this or any other logic I need to do.
If anyone could help me out on this,it would be very helpful for me.
You can easily achieve this by job-chaining your job executions. There are various approaches you can choose from:
(1) Implement a Quartz JobListener and in its jobWasExecuted method, that is invoked by Quartz whenever a job finishes executing, re-fire your job.
(2) Look at the Quartz JobChainingJobListener that you can use to implement simple job chaining scenarios. Please note that the functionality of this listener is very limited as it does not allow you to insert delays between job executions, there is no support for conditions that must be met before target jobs are executed etc. But you can use it as a good starting point to implement (1).
(3) Use QuartzDesk (our commercial product) or any other product that allows you to create job chains while externalizing and managing all job dependencies outside of your application. A job chain can have multiple target jobs that can be executed immediately, with a fixed delay or at arbitrary time in the future produced by a JavaScript expression. It also allows you to implement somewhat more sophisticated works flows, such as firing a target job when multiple source jobs complete their execution etc. I am attaching screenshots showing you what a simple job chain that re-executes Job1 with a 1 minute delay upon Job1's completion (with any job execution status) looks like: