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

    GridTcpDiscoverySpi disco = new GridTcpDiscoverySpi();

    disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
    disco.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(disco);

    if (gridName.endsWith("1")) cfg.setCacheConfiguration(); // Empty cache configuration.
    else {
      assert gridName.endsWith("2");

      GridCacheConfiguration cacheCfg = defaultCacheConfiguration();

      cacheCfg.setCacheMode(PARTITIONED);
      cacheCfg.setBackups(1);

      cfg.setCacheConfiguration(cacheCfg);
    }

    return cfg;
  }
示例#2
0
  /** @throws Exception If failed. */
  public void testLocalIfAffinityMapperIsWrongClass() throws Exception {
    g1Cfg.setCacheConfiguration(
        concat(dataCaches(1024), metaCaches(), GridCacheConfiguration.class));

    for (GridCacheConfiguration cc : g1Cfg.getCacheConfiguration())
      cc.setAffinityMapper(new GridCacheDefaultAffinityKeyMapper());

    checkGridStartFails(
        g1Cfg, "Invalid GGFS data cache configuration (key affinity mapper class should be", true);
  }
示例#3
0
  /** @throws Exception If failed. */
  public void testLocalIfNoMetadataCacheIsConfigured() throws Exception {
    GridCacheConfiguration cc = defaultCacheConfiguration();

    cc.setQueryIndexEnabled(false);
    cc.setName(dataCache1Name);

    g1Cfg.setCacheConfiguration(cc);

    checkGridStartFails(g1Cfg, "Metadata cache is not configured locally for GGFS", true);
  }
  /** {@inheritDoc} */
  @Override
  protected GridCacheConfiguration cacheConfiguration(String gridName) throws Exception {
    GridCacheConfiguration cfg = super.cacheConfiguration(gridName);

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

    return cfg;
  }
示例#5
0
  /** @throws Exception If failed. */
  public void testLocalIfBackupsEnabled() throws Exception {
    g1Cfg.setCacheConfiguration(
        concat(dataCaches(1024), metaCaches(), GridCacheConfiguration.class));

    for (GridCacheConfiguration cc : g1Cfg.getCacheConfiguration()) {
      cc.setCacheMode(PARTITIONED);
      cc.setBackups(1);
    }

    checkGridStartFails(g1Cfg, "GGFS data cache cannot be used with backups", true);
  }
示例#6
0
  /** @throws Exception If failed. */
  public void testLocalIfOffheapIsEnabledAndMaxSpaceSizeIsGreater() throws Exception {
    g1Cfg.setCacheConfiguration(
        concat(dataCaches(1024), metaCaches(), GridCacheConfiguration.class));

    for (GridCacheConfiguration cc : g1Cfg.getCacheConfiguration()) cc.setOffHeapMaxMemory(1000000);

    g1GgfsCfg2.setMaxSpaceSize(999999999999999999L);

    checkGridStartFails(
        g1Cfg,
        "Maximum GGFS space size cannot be greater than size of available heap memory and offheap storage",
        true);
  }
  /** @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;
  }
  /** {@inheritDoc} */
  @Override
  protected GridConfiguration getConfiguration(String gridName) throws Exception {
    GridConfiguration cfg = super.getConfiguration(gridName);

    GridCacheConfiguration cache = new GridCacheConfiguration();

    cache.setName(DATA_CACHE_NAME);

    cfg.setCacheConfiguration(cache);

    GridTcpDiscoverySpi disco = new GridTcpDiscoverySpi();

    disco.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(disco);

    return cfg;
  }
示例#9
0
  /**
   * @param cacheNames 2 Optional caches names.
   * @return 2 preconfigured meta caches.
   */
  private GridCacheConfiguration[] metaCaches(String... cacheNames) {
    assertTrue(ArrayUtils.isEmpty(cacheNames) || cacheNames.length == 2);

    if (ArrayUtils.isEmpty(cacheNames)) cacheNames = new String[] {metaCache1Name, metaCache2Name};

    GridCacheConfiguration[] res = new GridCacheConfiguration[cacheNames.length];

    for (int i = 0; i < cacheNames.length; i++) {
      GridCacheConfiguration metaCache = defaultCacheConfiguration();

      metaCache.setName(cacheNames[i]);
      metaCache.setAtomicityMode(TRANSACTIONAL);
      metaCache.setQueryIndexEnabled(false);

      res[i] = metaCache;
    }

    return res;
  }
  /** {@inheritDoc} */
  protected GridCacheConfiguration cacheConfiguration(String cacheName) {
    GridCacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setName(cacheName);

    if (META_CACHE_NAME.equals(cacheName)) cacheCfg.setCacheMode(REPLICATED);
    else {
      cacheCfg.setCacheMode(PARTITIONED);
      cacheCfg.setDistributionMode(GridCacheDistributionMode.PARTITIONED_ONLY);

      cacheCfg.setBackups(0);
      cacheCfg.setAffinityMapper(new GridGgfsGroupDataBlocksKeyMapper(CFG_GRP_SIZE));
    }

    cacheCfg.setWriteSynchronizationMode(GridCacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);
    cacheCfg.setQueryIndexEnabled(false);

    return cacheCfg;
  }
示例#11
0
  /**
   * @param grpSize Group size to use in {@link GridGgfsGroupDataBlocksKeyMapper}.
   * @param cacheNames 2 Optional caches names.
   * @return 2 preconfigured data caches.
   */
  private GridCacheConfiguration[] dataCaches(int grpSize, String... cacheNames) {
    assertTrue(ArrayUtils.isEmpty(cacheNames) || cacheNames.length == 2);

    if (ArrayUtils.isEmpty(cacheNames)) cacheNames = new String[] {dataCache1Name, dataCache2Name};

    GridCacheConfiguration[] res = new GridCacheConfiguration[cacheNames.length];

    for (int i = 0; i < cacheNames.length; i++) {
      GridCacheConfiguration dataCache = defaultCacheConfiguration();

      dataCache.setName(cacheNames[i]);
      dataCache.setAffinityMapper(new GridGgfsGroupDataBlocksKeyMapper(grpSize));
      dataCache.setAtomicityMode(TRANSACTIONAL);
      dataCache.setQueryIndexEnabled(false);

      res[i] = dataCache;
    }

    return res;
  }
  /** {@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;
  }
  /** {@inheritDoc} */
  @Override
  protected GridConfiguration getConfiguration() throws Exception {
    GridConfiguration c = super.getConfiguration();

    GridTcpDiscoverySpi disco = new GridTcpDiscoverySpi();

    disco.setIpFinder(new GridTcpDiscoveryVmIpFinder(true));

    c.setDiscoverySpi(disco);

    GridCacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(LOCAL);
    cc.setTxSerializableEnabled(true);

    cc.setDefaultTxTimeout(50);

    c.setCacheConfiguration(cc);

    c.setNetworkTimeout(1000);

    return c;
  }
  /**
   * @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;
  }
  /** {@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;
  }
  /**
   * Gets cache configuration.
   *
   * @return Cache configuration.
   */
  private GridCacheConfiguration[] cacheConfiguration() {
    GridCacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setName("partitioned");
    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setDistributionMode(GridCacheDistributionMode.PARTITIONED_ONLY);
    cacheCfg.setWriteSynchronizationMode(GridCacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setAffinityMapper(new GridGgfsGroupDataBlocksKeyMapper(GRP_SIZE));
    cacheCfg.setBackups(0);
    cacheCfg.setQueryIndexEnabled(false);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);

    GridCacheConfiguration metaCacheCfg = defaultCacheConfiguration();

    metaCacheCfg.setName("replicated");
    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setWriteSynchronizationMode(GridCacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setQueryIndexEnabled(false);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    return new GridCacheConfiguration[] {metaCacheCfg, cacheCfg};
  }