-
Notifications
You must be signed in to change notification settings - Fork 354
Task scheduler
elandau edited this page Nov 30, 2012
·
9 revisions
Experimental and not yet released !!!
This is a Quartz like task scheduler where you can register a task class, task metadata and scheduling details. The recipe builds on top of the Durable Message Queue recipe for scheduling the next execution time and persists task details in a separate column family.
TODO
The first step to using the scheduler is to create a DistributedTaskScheduler instance.
TaskScheduler scheduler = new DistributedTaskScheduler.Builder()
.withBatchSize(5)
.withKeyspace(keyspace)
.withName("TestScheduler")
.build();
First, you must define a task processing class.
public class HelloWorldTask implements Task {
@Override
public void execute(TaskInfo task) {
System.out.println("Hello World!");
}
}
Next, schedule a task and give it a trigger. This example shows how to create a task that will execute every hour starting from now and will repeat 5 times. The scheduler will also keep a status history of every task execution.
scheduler.scheduleTask(
new TaskInfo.Builder()
.withKey("MyHelloWorld")
.withClass(HelloWorldTask.class)
.withHistory(true)
.build()
,
new RepeatingTrigger.Builder()
.withInterval(1, TimeUnit.HOURS)
.withRepeatCount(5)
.build()
);
A Netflix Original Production
Tech Blog | Twitter @NetflixOSS | Jobs
- Getting-Started
- Configuration
- Features
- Monitoring
- Thread Safety
- Timeouts
- Recipes
- Examples
- Javadoc
- Utilities
- Cassandra-Compatibility
- FAQ
- End-to-End Examples
- Astyanax Integration with Java Driver