/**
     * Checks state of the bean.
     *
     * @param gridName Grid name.
     * @param exec Try to execute something on the grid.
     */
    void checkState(String gridName, boolean exec) {
      assert log != null;
      assert appCtx != null;

      assert F.eq(gridName, ignite.name());

      if (exec)
        // Execute any grid method.
        G.ignite(gridName).events().localQuery(F.<Event>alwaysTrue());
    }
  /** @throws Exception If failed. */
  public void testCustomClosure() throws Exception {
    for (int i = 0; i < NODES_CNT; i++) {
      log.info("Iteration: " + i);

      Ignite ignite = grid(i);

      Collection<String> res =
          ignite
              .compute(ignite.cluster().forPredicate(F.<ClusterNode>alwaysTrue()))
              .broadcast(
                  new IgniteCallable<String>() {
                    @IgniteInstanceResource Ignite ignite;

                    @Override
                    public String call() throws Exception {
                      return ignite.name();
                    }
                  });

      assertEquals(NODES_CNT, res.size());
    }
  }