/**
   * Creates grid configuration.
   *
   * @param gridName Grid name.
   * @return Grid configuration.
   * @throws Exception If error occurred.
   */
  private static GridConfiguration getConfiguration(String gridName) throws Exception {
    GridConfiguration cfg = new GridConfiguration();

    cfg.setGridName(gridName);
    cfg.setGridLogger(new GridLog4jLogger());
    cfg.setRestEnabled(false);

    return cfg;
  }
Пример #2
0
  /**
   * Starts new grid node.
   *
   * @param gridName name of new node.
   * @param springCfg file with spring configuration to use for this node.
   * @return a grid instance local to new node {@link GridGain#start(GridConfiguration)}.
   * @throws Exception if node run failed.
   */
  protected Grid startNode(String gridName, File springCfg) throws Exception {
    assert springCfg != null;

    ListableBeanFactory springCtx =
        new FileSystemXmlApplicationContext("file:///" + springCfg.getAbsolutePath());

    Map cfgMap = springCtx.getBeansOfType(GridConfiguration.class);

    assert cfgMap != null;
    assert !cfgMap.isEmpty();

    GridConfiguration cfg = (GridConfiguration) cfgMap.values().iterator().next();

    cfg.setGridName(gridName + "-" + getNextNodeNum());

    return G.start(cfg);
  }