/** @return Cache configuration. */
  private GridCacheConfiguration cacheConfiguration() {
    GridCacheConfiguration cfg = new GridCacheConfiguration();

    cfg.setBackups(backups);

    cfg.setCacheMode(GridCacheMode.PARTITIONED);

    cfg.setDistributionMode(GridCacheDistributionMode.PARTITIONED_ONLY);

    cfg.setAffinity(new GridCachePartitionFairAffinity(parts));

    return cfg;
  }
コード例 #2
0
  /**
   * @param cacheName Cache name.
   * @return Cache configuration.
   * @throws Exception In case of error.
   */
  private GridCacheConfiguration cacheConfiguration(@Nullable String cacheName) throws Exception {
    GridCacheConfiguration cfg = defaultCacheConfiguration();

    cfg.setAtomicityMode(TRANSACTIONAL);
    cfg.setDistributionMode(NEAR_PARTITIONED);

    if (cacheName == null) cfg.setCacheMode(LOCAL);
    else if (PARTITIONED_CACHE_NAME.equals(cacheName)) {
      cfg.setCacheMode(PARTITIONED);

      cfg.setBackups(0);
    } else cfg.setCacheMode(REPLICATED);

    cfg.setName(cacheName);

    cfg.setWriteSynchronizationMode(
        REPLICATED_ASYNC_CACHE_NAME.equals(cacheName) ? FULL_ASYNC : FULL_SYNC);

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

    if (cache) {
      GridCacheConfiguration cacheCfg = defaultCacheConfiguration();

      cacheCfg.setCacheMode(PARTITIONED);
      cacheCfg.setBackups(1);
      cacheCfg.setDistributionMode(nearOnly ? NEAR_ONLY : NEAR_PARTITIONED);
      cacheCfg.setPreloadMode(SYNC);
      cacheCfg.setAtomicityMode(TRANSACTIONAL);

      cfg.setCacheConfiguration(cacheCfg);
    }

    GridTcpDiscoverySpi discoSpi = new GridTcpDiscoverySpi();

    discoSpi.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(discoSpi);

    return cfg;
  }