Skip to content

Instantly share code, notes, and snippets.

@kpiwko
Created April 23, 2014 14:15
Show Gist options
  • Select an option

  • Save kpiwko/11216846 to your computer and use it in GitHub Desktop.

Select an option

Save kpiwko/11216846 to your computer and use it in GitHub Desktop.
scheduling a callable for spacelift
Tasks.prepare(CreateFileTask.class)
.named("target/foobar")
.then(DataSampler.class)
.generateRandomData(123)
.then(FileReader.class)
.then(ExecutionCounter.class)
.execute().awaitUntil(3, TimeUnit.SECONDS, new ExecutionCondition<Integer>() {
@Override
public boolean satisfiedBy(Integer object) throws ExecutionException {
return object >= 3;
}
});
// restart counter
Tasks.prepare(ExecutionCounter.class).restart();
exception.expect(TimeoutExecutionException.class);
Tasks.prepare(CreateFileTask.class)
.named("target/foobar")
.then(DataSampler.class)
.generateRandomData(123)
.then(FileReader.class)
.then(ExecutionCounter.class)
.execute()
.pollEvery(1, TimeUnit.SECONDS).awaitUntil(3, TimeUnit.SECONDS, new ExecutionCondition<Integer>() {
@Override
public boolean satisfiedBy(Integer object) throws ExecutionException {
return object >= 5;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment