GridGain 6中的GridJexlPredicate2的替代品是什么(开源版本)

时间:2014-04-11 22:58:14

标签: grid-computing gridgain

我们正在将应用程序从旧的gridgain 4代码库迁移到gridgain 6.在旧的应用程序中,我们使用GridJexlPredicate2绑定到一个监视器方法,该方法确定一个节点是否应该运行特定的作业(基本上,检查如果节点包含特定的属性值)。

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

由于

/**
* 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);
}

1 个答案:

答案 0 :(得分:1)

另一种方法是使用GridProjection和过滤器

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();