cambunctious
cambunctious

Reputation: 9582

Run a task once at a time in the ignite cluster

I have a task to run continuously on one node in the ignite cluster. When the task completes or fails, it should be started again on the oldest node. How can I do this?

class MyTask {

    @PostConstruct()
    public void start() {
        ignite.executorService(ignite.cluster().forOldest())
                .submit(() -> myTask());
    }
}

Upvotes: 0

Views: 153

Answers (1)

Evgenii Zhuravlev
Evgenii Zhuravlev

Reputation: 3017

You can start singleton Ignite Service(https://apacheignite.readme.io/docs/service-grid) with a filter for the oldest node. It will guarantee failover safety.

Inside service's "execute" method, you can have while loop with starting the task. Using that, you can handle task completing and failing and restart it again.

Upvotes: 3

Related Questions