1. If you don't care to balance the execution then let the first
member in the cluster always execute the cron job.
Set<Member> members = Hazelcast.getCluster.getMembers();
if (members.next().localMember()) { // only first member will execute
the scheduled cron job.
cronjob.run();
}
2. If you want to balance the execution then let the first member fire
the execution of the cron job in the cluster.
Set<Member> members = Hazelcast.getCluster.getMembers();
if (members.next().localMember()) {
Hazelcast.getExecutorService().execute(cronjob); // execute
the cron job somewhere in the cluster.
}
AtomicNumber counter = Hazelcast.getAtomicNumber(cronJobName);
long current = counter.get();
if (counter.compareAndSet(current, current+1)) {
cronjob.run();
}
Object cronJobId = cronjob.getId();
Set set
Lock lock = Hazelcast.getLock(cronJobId);
lock.lock();
if (
cronjob.run();
lock.unlock();
twitter @oztalip
> --
> You received this message because you are subscribed to the Google Groups "Hazelcast" group.
> To post to this group, send email to haze...@googlegroups.com.
> To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.
>
>
twitter @oztalip