Runnable
和Callable
的实例在本地节点可以使用IgniteScheduler.scheduleLocal()
方法和Cron
语法进行调度用于周期性的执行
示例:
Ignite ignite = Ignition.start(cfg); Collection<ClusterNode> nodes = ignite.cluster().nodes(); ClusterNode useNode = null; for (ClusterNode node : nodes) { if(node.isClient()){ useNode = node; } if(null != useNode){ break; } } ignite.compute(ignite.cluster().forNodeId(useNode.id())).call(new IgniteCallable<Object>() { @IgniteInstanceResource Ignite ignite; @Override public Object call() throws Exception { ignite.scheduler().scheduleLocal(new Runnable() { @Override public void run() { System.out.println("test"); } }, "* * * * *");//每分钟执行一次 最小力度分钟,第一次调度时间不定 return null; } });
scheduler支持配置延迟执行和执行次数
此外仓库中当前没有2.14版本ignite-schedule包,部署时需要额外添加包
部署包需要添加ignite-scheduler 依赖 1.2.0-incubating 无最新版本
lass org.apache.ignite.IgniteException: Current Ignite configuration does not support schedule functionality (consider adding ignite-schedule module to classpath).
标签:ignite,Ignite,useNode,schedule,调度,Cron,scheduler,nodes From: https://www.cnblogs.com/yangh2016/p/17127155.html