首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在GridJexlPredicate2 6(开放源码版本)中,有什么替代GridGain的方法?

在GridJexlPredicate2 6(开放源码版本)中,有什么替代GridGain的方法?
EN

Stack Overflow用户
提问于 2014-04-11 22:58:13
回答 1查看 48关注 0票数 0

在旧的应用程序中,我们使用GridJexlPredicate2连接到一个监视方法,该方法确定节点是否应该运行特定的作业(基本上,检查节点是否包含特定的属性值)。

在gridgain 6中,我怀疑我们应该使用GridBiPredicate类。但是,基于表达式语言的GridJexlPredicate2类是否有替代品,或者是否有不同的编程/声明性方法呢?

谢谢

代码语言:javascript
复制
/**
* Creates the topology filter used to select nodes for processing.
* The expression string will have three variables that can be referenced:
* <dl>
* <dt><strong>node</strong></dt>
* <dd>The GridNode being tested</dd>
* <dt><strong>session</strong></dt>
* <dd>The GridTaskSession for the task being executed</dd>
* <dt><strong>monitor</strong></dt>
* <dd>The GridNodeMonitor monitoring nodes on the grid</dd>
* </dl>
*
* @param monitor The monitor instance to be bound into the expression
*context for use in the filter expression
* @return A {@link GridBiPredicate} used to filter nodes
*/
  public static GridJexlPredicate2<GridNode, GridComputeTaskSession>    createTopologyFilter(GridNodeMonitor monitor) {
    GridJexlPredicate2<GridNode, GridComputeTaskSession> filter = new GridJexlPredicate2<GridNode, GridComputeTaskSession>("monitor.canAcceptJobs(node)","node", "session");
    return filter.with("monitor", monitor);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-12 03:04:25

另一种方法是将GridProjection与过滤器一起使用。

代码语言:javascript
复制
final MyNodeMonitor monitor = ...;

Grid grid = GridGain.gridI();

GridProjection prj = grid.forPredicate(new GridPredicate<GridNode>() {
    @Override public boolean apply(GridNode node) {
        return monitor.canAcceptJobs(node);
    }
});

GridComputeTaskFuture<?> fut = prj.compute().execute(new MyTask());

// Synchronous wait.
fut.get();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23023924

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档