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

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(IP_FINDER);

    cfg.getTransactionConfiguration().setTxSerializableEnabled(true);

    cfg.setDiscoverySpi(disco);

    BasicWarmupClosure warmupClosure = new BasicWarmupClosure();

    warmupClosure.setGridCount(2);
    warmupClosure.setIterationCount(10);
    warmupClosure.setKeyRange(10);

    cfg.setWarmupClosure(warmupClosure);

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

    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    cacheCfg.setBackups(1);
    cacheCfg.setName("test");

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
  }
  /**
   * @return Cache configuration.
   * @throws Exception In case of error.
   */
  protected CacheConfiguration cacheConfiguration() throws Exception {
    CacheConfiguration cfg = defaultCacheConfiguration();

    cfg.setCacheMode(PARTITIONED);
    cfg.setBackups(1);
    cfg.setWriteSynchronizationMode(FULL_SYNC);
    cfg.setRebalanceMode(SYNC);

    return cfg;
  }
  /**
   * @param name Cache name.
   * @param cacheMode Cache mode.
   * @param parts Number of partitions.
   * @return Cache configuration.
   */
  private CacheConfiguration cacheConfiguration(String name, CacheMode cacheMode, int parts) {
    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setName(name);
    ccfg.setCacheMode(cacheMode);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);

    if (cacheMode == PARTITIONED) ccfg.setBackups(1);

    ccfg.setAffinity(new RendezvousAffinityFunction(false, parts));

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

    TcpDiscoverySpi spi = new TcpDiscoverySpi();

    spi.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(spi);

    cfg.setIncludeProperties();

    cfg.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED);

    cfg.setConnectorConfiguration(null);

    cfg.setPeerClassLoadingEnabled(true);

    if (useCache) {
      CacheConfiguration cc = defaultCacheConfiguration();

      cc.setCacheMode(PARTITIONED);

      cc.setNearConfiguration(null);
      cc.setWriteSynchronizationMode(FULL_SYNC);
      cc.setStartSize(ENTRY_CNT / GRID_CNT);
      cc.setSwapEnabled(false);

      cc.setBackups(1);

      cfg.setCacheSanityCheckEnabled(false);
      cfg.setCacheConfiguration(cc);
    } else cfg.setCacheConfiguration();

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

    TcpDiscoverySpi spi = new TcpDiscoverySpi();

    spi.setIpFinder(ipFinder);

    c.setDiscoverySpi(spi);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setName("test");
    cc.setCacheMode(PARTITIONED);
    cc.setWriteSynchronizationMode(FULL_SYNC);
    cc.setAtomicityMode(TRANSACTIONAL);
    cc.setNearConfiguration(null);

    c.setCacheConfiguration(cc);

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

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(ipFinder);

    c.setDiscoverySpi(disco);

    CacheConfiguration<?, ?> cc = defaultCacheConfiguration();

    cc.setCacheMode(PARTITIONED);
    cc.setBackups(1);
    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cc.setAtomicityMode(TRANSACTIONAL);
    cc.setIndexedTypes(Integer.class, Integer.class);

    c.setCacheConfiguration(cc);

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

    TransactionConfiguration txCfg = c.getTransactionConfiguration();

    txCfg.setDefaultTxConcurrency(txConcurrency);
    txCfg.setDefaultTxIsolation(txIsolation);
    txCfg.setTxSerializableEnabled(true);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(cacheMode());
    cc.setAtomicityMode(TRANSACTIONAL);

    cc.setSwapEnabled(false);

    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);

    cc.setEvictionPolicy(plc);
    cc.setEvictSynchronizedKeyBufferSize(1);

    cc.setEvictSynchronized(true);

    if (testStore != null) {
      cc.setCacheStoreFactory(singletonFactory(testStore));
      cc.setReadThrough(true);
      cc.setWriteThrough(true);
      cc.setLoadPreviousValue(true);
    } else cc.setCacheStoreFactory(null);

    c.setCacheConfiguration(cc);

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(ipFinder);

    c.setDiscoverySpi(disco);

    return c;
  }