コード例 #1
0
  /**
   * Create Grid configuration with configured checkpoints.
   *
   * @return Grid configuration.
   * @throws GridException If configuration creation failed.
   */
  public static GridConfiguration configuration() throws GridException {
    GridConfiguration cfg = new GridConfiguration();

    cfg.setLocalHost("127.0.0.1");
    cfg.setPeerClassLoadingEnabled(true);

    GridOptimizedMarshaller marsh = new GridOptimizedMarshaller();

    marsh.setRequireSerializable(false);

    cfg.setMarshaller(marsh);

    cfg.setDeploymentSpi(new GridUriDeploymentSpi());

    GridTcpDiscoverySpi discoSpi = new GridTcpDiscoverySpi();

    GridTcpDiscoveryVmIpFinder ipFinder = new GridTcpDiscoveryVmIpFinder();

    ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));

    discoSpi.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(discoSpi);

    return cfg;
  }
コード例 #2
0
  /** {@inheritDoc} */
  @Override
  protected GridConfiguration getConfiguration(String gridName) throws Exception {
    GridConfiguration cfg = super.getConfiguration(gridName);

    GridTcpDiscoverySpi discoSpi = new GridTcpDiscoverySpi();
    discoSpi.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(discoSpi);

    cfg.setCommunicationSpi(new CommunicationSpi());
    cfg.setMarshaller(new GridOptimizedMarshaller(false));

    GridCacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setCacheMode(PARTITIONED);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
  }