0

アプリケーションを古い 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);
}
4

1 に答える 1

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();
于 2014-04-12T03:04:25.700 に答える