/** {@inheritDoc} */
  @Override
  protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    assertNotNull(clientNodes);

    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);

    boolean client = false;

    for (Integer clientIdx : clientNodes) {
      if (getTestGridName(clientIdx).equals(gridName)) {
        client = true;

        break;
      }
    }

    cfg.setClientMode(client);

    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setBackups(0);
    ccfg.setRebalanceMode(SYNC);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
  }
  /** {@inheritDoc} */
  @Override
  protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);

    if (gridName.equals(getTestGridName(GRID_CNT - 1))) cfg.setClientMode(true);

    return cfg;
  }
  /** {@inheritDoc} */
  @Override
  protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration iCfg = super.getConfiguration(gridName);

    ((TcpDiscoverySpi) iCfg.getDiscoverySpi()).setIpFinder(ipFinder);
    ((TcpDiscoverySpi) iCfg.getDiscoverySpi()).setForceServerMode(true);

    if (getTestGridName(10).equals(gridName)) iCfg.setClientMode(true);

    CacheConfiguration<Integer, Integer> cachePCfg = new CacheConfiguration<>();

    cachePCfg.setName(CACHE_NAME_DHT_PARTITIONED);
    cachePCfg.setCacheMode(CacheMode.PARTITIONED);
    cachePCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    cachePCfg.setBackups(1);
    cachePCfg.setRebalanceBatchSize(1);
    cachePCfg.setRebalanceBatchesPrefetchCount(1);
    cachePCfg.setRebalanceOrder(2);

    CacheConfiguration<Integer, Integer> cachePCfg2 = new CacheConfiguration<>();

    cachePCfg2.setName(CACHE_NAME_DHT_PARTITIONED_2);
    cachePCfg2.setCacheMode(CacheMode.PARTITIONED);
    cachePCfg2.setRebalanceMode(CacheRebalanceMode.SYNC);
    cachePCfg2.setBackups(1);
    cachePCfg2.setRebalanceOrder(2);
    // cachePCfg2.setRebalanceDelay(5000);//Known issue, possible deadlock in case of low priority
    // cache rebalancing delayed.

    CacheConfiguration<Integer, Integer> cacheRCfg = new CacheConfiguration<>();

    cacheRCfg.setName(CACHE_NAME_DHT_REPLICATED);
    cacheRCfg.setCacheMode(CacheMode.REPLICATED);
    cacheRCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    cacheRCfg.setRebalanceBatchSize(1);
    cacheRCfg.setRebalanceBatchesPrefetchCount(Integer.MAX_VALUE);
    ((TcpCommunicationSpi) iCfg.getCommunicationSpi())
        .setSharedMemoryPort(-1); // Shmem fail fix for Integer.MAX_VALUE.

    CacheConfiguration<Integer, Integer> cacheRCfg2 = new CacheConfiguration<>();

    cacheRCfg2.setName(CACHE_NAME_DHT_REPLICATED_2);
    cacheRCfg2.setCacheMode(CacheMode.REPLICATED);
    cacheRCfg2.setRebalanceMode(CacheRebalanceMode.SYNC);
    cacheRCfg2.setRebalanceOrder(4);

    iCfg.setCacheConfiguration(cachePCfg, cachePCfg2, cacheRCfg, cacheRCfg2);

    iCfg.setRebalanceThreadPoolSize(2);

    return iCfg;
  }
  /** {@inheritDoc} */
  @Override
  protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    cfg.setMarshaller(new OptimizedMarshaller(false));

    cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder).setForceServerMode(true));

    cfg.setCacheConfiguration();

    if (gridName.equals(getTestGridName(0))) cfg.setClientMode(true);

    return cfg;
  }
  /** {@inheritDoc} */
  @Override
  protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);

    if (gridName.equals(getTestGridName(GRID_CNT - 1))) cfg.setClientMode(true);

    cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());

    ((TcpCommunicationSpi) cfg.getCommunicationSpi()).setSharedMemoryPort(-1);

    return cfg;
  }
  /** {@inheritDoc} */
  @SuppressWarnings({"IfMayBeConditional"})
  @Override
  protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    if (client()) cfg.setClientMode(true);

    cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));

    cfg.setCacheConfiguration();

    cfg.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED);

    cfg.setIncludeProperties();

    return cfg;
  }
  /** {@inheritDoc} */
  @Override
  protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);

    CacheConfiguration ccfg1 = new CacheConfiguration();

    ccfg1.setBackups(1);
    ccfg1.setName(CACHE1);
    ccfg1.setAffinity(new RendezvousAffinityFunction());
    ccfg1.setNodeFilter(new TestNodesFilter());

    CacheConfiguration ccfg2 = new CacheConfiguration();

    ccfg2.setBackups(1);
    ccfg2.setName(CACHE2);
    ccfg2.setAffinity(new RendezvousAffinityFunction());

    CacheConfiguration ccfg3 = new CacheConfiguration();

    ccfg3.setBackups(1);
    ccfg3.setName(CACHE3);
    ccfg3.setAffinity(new FairAffinityFunction());
    ccfg3.setNodeFilter(new TestNodesFilter());

    CacheConfiguration ccfg4 = new CacheConfiguration();

    ccfg4.setCacheMode(REPLICATED);
    ccfg4.setName(CACHE4);
    ccfg4.setNodeFilter(new TestNodesFilter());

    CacheConfiguration ccfg5 = new CacheConfiguration();

    ccfg5.setBackups(1);
    ccfg5.setName(CACHE5);

    if (gridName.equals(getTestGridName(NODE_CNT - 1))) {
      cfg.setClientMode(true);

      cfg.setCacheConfiguration(ccfg5);
    } else cfg.setCacheConfiguration(ccfg1, ccfg2, ccfg3, ccfg4);

    return cfg;
  }
  /** {@inheritDoc} */
  @Override
  protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    if (getTestGridName(0).equals(gridName)) {
      cfg.setClientMode(true);

      cfg.setCacheConfiguration();
    }

    if (getTestGridName(10).equals(gridName)) {

      CacheConfiguration cc = cfg.getCacheConfiguration()[0];
      cc.setRebalanceDelay(-1);
    }

    return cfg;
  }
Ejemplo n.º 9
0
  /**
   * Configure node.
   *
   * @param gridIdx Grid name index.
   * @param client If {@code true} then start client node.
   * @return IgniteConfiguration
   */
  private static IgniteConfiguration igniteConfiguration(int gridIdx, boolean client) {
    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setGridName((client ? "demo-server-" : "demo-client-") + gridIdx);

    cfg.setLocalHost("127.0.0.1");

    cfg.setIncludeEventTypes(EVTS_DISCOVERY);

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

    ipFinder.setAddresses(Collections.singletonList("127.0.0.1:60900.." + (60900 + NODE_CNT - 1)));

    // Configure discovery SPI.
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setLocalPort(60900);

    discoSpi.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(discoSpi);

    TcpCommunicationSpi commSpi = new TcpCommunicationSpi();

    commSpi.setSharedMemoryPort(-1);

    commSpi.setLocalPort(60800);

    cfg.setCommunicationSpi(commSpi);

    cfg.setGridLogger(new Log4JLogger(log));

    cfg.setMetricsLogFrequency(0);

    cfg.getConnectorConfiguration().setPort(60700);

    if (client) cfg.setClientMode(true);
    else
      cfg.setCacheConfiguration(
          cacheCountry(), cacheDepartment(), cacheEmployee(), cacheParking(), cacheCar());

    return cfg;
  }