@Override
  protected void afterSitesCreated() {
    super.afterSitesCreated();

    ConfigurationBuilder builder = newConfiguration();
    builder.sites().addBackup().site(siteName(2)).strategy(BackupConfiguration.BackupStrategy.SYNC);
    defineInSite(site(0), CacheType.BACKUP_TO_SITE_2.name(), builder.build());
    defineInSite(site(2), CacheType.BACKUP_TO_SITE_2.name(), newConfiguration().build());

    builder = newConfiguration();
    builder.sites().addBackup().site(siteName(1)).strategy(BackupConfiguration.BackupStrategy.SYNC);
    builder.sites().addBackup().site(siteName(2)).strategy(BackupConfiguration.BackupStrategy.SYNC);
    defineInSite(site(0), CacheType.BACKUP_TO_SITE_1_AND_2.name(), builder.build());
    defineInSite(site(1), CacheType.BACKUP_TO_SITE_1_AND_2.name(), newConfiguration().build());
    defineInSite(site(2), CacheType.BACKUP_TO_SITE_1_AND_2.name(), newConfiguration().build());

    defineInSite(site(0), CacheType.NO_BACKUP.name(), newConfiguration().build());

    // wait for caches in primary cluster
    site(0).waitForClusterToForm(null);
    site(0).waitForClusterToForm(CacheType.BACKUP_TO_SITE_1_AND_2.name());
    site(0).waitForClusterToForm(CacheType.BACKUP_TO_SITE_1_AND_2.name());
    site(0).waitForClusterToForm(CacheType.BACKUP_TO_SITE_2.name());

    // wait for caches in backup site 1
    site(1).waitForClusterToForm(null);
    site(1).waitForClusterToForm(CacheType.BACKUP_TO_SITE_1_AND_2.name());

    // wait for caches in backup site 2
    site(2).waitForClusterToForm(CacheType.BACKUP_TO_SITE_1_AND_2.name());
    site(2).waitForClusterToForm(CacheType.BACKUP_TO_SITE_2.name());
  }
 private HotRodServer addHotRodServer() {
   EmbeddedCacheManager cm = addClusterEnabledCacheManager(defaultBuilder);
   cm.defineConfiguration(DIST_ONE_CACHE_NAME, distOneBuilder.build());
   cm.defineConfiguration(DIST_TWO_CACHE_NAME, distTwoBuilder.build());
   HotRodServer server = HotRodClientTestingUtil.startHotRodServer(cm);
   addr2hrServer.put(new InetSocketAddress(server.getHost(), server.getPort()), server);
   return server;
 }
  private Cache<K, V> configureAndCreateNamedCache(final String cacheName) {
    switch (this.configurationTemplateMode) {
      case NONE:
        this.logger.debug("ConfigurationTemplateMode is NONE: using a fresh Configuration");
        if (this.infinispanEmbeddedCacheManager.getCacheNames().contains(cacheName)) {
          throw new IllegalStateException(
              "Cannot use ConfigurationTemplateMode NONE: a cache named ["
                  + cacheName
                  + "] has already been defined.");
        }
        builder = new ConfigurationBuilder();
        this.infinispanEmbeddedCacheManager.defineConfiguration(cacheName, builder.build());
        break;
      case NAMED:
        this.logger.debug(
            "ConfigurationTemplateMode is NAMED: using a named Configuration [" + cacheName + "]");
        Configuration cacheConfiguration =
            infinispanEmbeddedCacheManager.getCacheConfiguration(cacheName);
        if (cacheConfiguration != null) {
          builder = new ConfigurationBuilder();
          builder.read(cacheConfiguration);
          this.infinispanEmbeddedCacheManager.defineConfiguration(cacheName, builder.build());
        }
        break;
      case DEFAULT:
        this.logger.debug("ConfigurationTemplateMode is DEFAULT.");
        if (this.infinispanEmbeddedCacheManager.getCacheNames().contains(cacheName)) {
          throw new IllegalStateException(
              "Cannot use ConfigurationTemplateMode DEFAULT: a cache named ["
                  + cacheName
                  + "] has already been defined.");
        }
        break;
      case CUSTOM:
        this.logger.debug(
            "ConfigurationTemplateMode is CUSTOM. Using the provided ConfigurationBuilder.");
        if (this.builder == null) {
          throw new IllegalStateException(
              "There has not been a ConfigurationBuilder provided. There has to be one "
                  + "provided for ConfigurationTemplateMode CUSTOM.");
        }
        this.infinispanEmbeddedCacheManager.defineConfiguration(cacheName, builder.build());
        break;
      default:
        throw new IllegalStateException(
            "Unknown ConfigurationTemplateMode: " + this.configurationTemplateMode);
    }

    return this.infinispanEmbeddedCacheManager.getCache(cacheName);
  }
Пример #4
0
  private void createRemoteValueWrapperInterceptor(ComponentRegistry cr, Configuration cfg) {
    RemoteValueWrapperInterceptor wrapperInterceptor =
        cr.getComponent(RemoteValueWrapperInterceptor.class);
    if (wrapperInterceptor == null) {
      wrapperInterceptor = new RemoteValueWrapperInterceptor();

      // Interceptor registration not needed, core configuration handling
      // already does it for all custom interceptors - UNLESS the InterceptorChain already exists in
      // the component registry!
      AsyncInterceptorChain ic = cr.getComponent(AsyncInterceptorChain.class);

      ConfigurationBuilder builder = new ConfigurationBuilder().read(cfg);
      InterceptorConfigurationBuilder interceptorBuilder =
          builder.customInterceptors().addInterceptor();
      interceptorBuilder.interceptor(wrapperInterceptor);

      if (cfg.invocationBatching().enabled()) {
        if (ic != null) ic.addInterceptorAfter(wrapperInterceptor, BatchingInterceptor.class);
        interceptorBuilder.after(BatchingInterceptor.class);
      } else {
        if (ic != null)
          ic.addInterceptorAfter(wrapperInterceptor, InvocationContextInterceptor.class);
        interceptorBuilder.after(InvocationContextInterceptor.class);
      }
      if (ic != null) {
        cr.registerComponent(wrapperInterceptor, RemoteValueWrapperInterceptor.class);
      }
      cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors());
    }
  }
 public void testDisabledInterceptorStack() {
   ConfigurationBuilder cfg = new ConfigurationBuilder();
   cfg.storeAsBinary().disable();
   cm.defineConfiguration("a", cfg.build());
   Cache<?, ?> c = cm.getCache("a");
   assert TestingUtil.findInterceptor(c, MarshalledValueInterceptor.class) == null;
 }
  @Override
  protected void createCacheManagers() throws Throwable {
    ConfigurationBuilder defaultConfiguration =
        getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, false);
    defaultConfiguration.clustering().stateTransfer().fetchInMemoryState(true);
    createClusteredCaches(2, defaultConfiguration);

    ConfigurationBuilder cfg = initialCacheConfiguration();
    cfg.clustering()
        .stateTransfer()
        .fetchInMemoryState(true)
        .indexing()
        .index(Index.LOCAL)
        .addIndexedEntity(getModelFactory().getUserImplClass())
        .addIndexedEntity(getModelFactory().getAccountImplClass())
        .addIndexedEntity(getModelFactory().getTransactionImplClass())
        .addProperty(
            "default.indexmanager", "org.infinispan.query.indexmanager.InfinispanIndexManager")
        .addProperty("lucene_version", "LUCENE_CURRENT");

    manager(0).defineConfiguration(TEST_CACHE_NAME, cfg.build());
    manager(1).defineConfiguration(TEST_CACHE_NAME, cfg.build());
    cache1 = manager(0).getCache(TEST_CACHE_NAME);
    cache2 = manager(1).getCache(TEST_CACHE_NAME);
  }
 @Test
 public void testBuildDiffCacheNameTimestampsRegion() {
   final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
   Properties p = createProperties();
   p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "unrecommended-timestamps");
   InfinispanRegionFactory factory = createRegionFactory(p);
   try {
     EmbeddedCacheManager manager = factory.getCacheManager();
     assertFalse(factory.getDefinedConfigurations().contains("timestamp"));
     assertTrue(factory.getDefinedConfigurations().contains("unrecommended-timestamps"));
     assertTrue(
         factory
             .getTypeOverrides()
             .get("timestamps")
             .getCacheName()
             .equals("unrecommended-timestamps"));
     ConfigurationBuilder builder = new ConfigurationBuilder();
     builder.clustering().stateTransfer().fetchInMemoryState(true);
     builder.clustering().cacheMode(CacheMode.REPL_SYNC);
     manager.defineConfiguration("unrecommended-timestamps", builder.build());
     TimestampsRegionImpl region =
         (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
     AdvancedCache cache = region.getCache();
     Configuration cacheCfg = cache.getCacheConfiguration();
     assertEquals(EvictionStrategy.NONE, cacheCfg.eviction().strategy());
     assertEquals(CacheMode.REPL_SYNC, cacheCfg.clustering().cacheMode());
     assertFalse(cacheCfg.storeAsBinary().enabled());
     assertFalse(cacheCfg.jmxStatistics().enabled());
   } finally {
     factory.stop();
   }
 }
Пример #8
0
 public void testBackupForIsCorrect() {
   cacheManager.getCache(); // start default cache
   cacheManager.defineConfiguration("nycBackup", nycBackup.build());
   cacheManager.getCache("nycBackup");
   SitesConfiguration sitesConfig = cache("nycBackup").getCacheConfiguration().sites();
   assertEquals(CacheContainer.DEFAULT_CACHE_NAME, sitesConfig.backupFor().remoteCache());
   assertEquals("NYC", sitesConfig.backupFor().remoteSite());
   sitesConfig.backupFor().isBackupFor("NYC", CacheContainer.DEFAULT_CACHE_NAME);
 }
Пример #9
0
 @Test
 public void testDummyTMGetCache() {
   ConfigurationBuilder cb = new ConfigurationBuilder();
   cb.transaction()
       .use1PcForAutoCommitTransactions(true)
       .transactionManagerLookup(new DummyTransactionManagerLookup());
   DefaultCacheManager cm = new DefaultCacheManager(cb.build());
   cm.getCache();
 }
 private Configuration buildConfiguration(boolean tx) {
   ConfigurationBuilder cb = getDefaultClusteredCacheConfig(CacheMode.REPL_ASYNC, tx);
   cb.clustering().async().useReplQueue(true).replQueueInterval(100).replQueueMaxElements(3);
   // These are the default:
   // .asyncMarshalling(false)
   // .stateTransfer().fetchInMemoryState(true)
   // .locking().useLockStriping(false);
   return cb.build();
 }
Пример #11
0
 @Override
 protected EmbeddedCacheManager createCacheManager() throws Exception {
   // start a single cache instance
   ConfigurationBuilder c = getDefaultStandaloneCacheConfig(true);
   c.storeAsBinary().enable();
   EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(false);
   cm.defineConfiguration("lazy-cache-test", c.build());
   cache = cm.getCache("lazy-cache-test");
   return cm;
 }
Пример #12
0
 /**
  * Create a cache container using the supplied configurations.
  *
  * @param globalConfigurationBuilder the global configuration builder
  * @param configurationBuilder the default cache configuration builder
  * @return the cache container
  */
 protected CacheContainer createContainer(
     GlobalConfigurationBuilder globalConfigurationBuilder,
     ConfigurationBuilder configurationBuilder) {
   GlobalConfiguration globalConfiguration = globalConfigurationBuilder.build();
   Configuration configuration = configurationBuilder.build();
   logger.debug(
       "Starting cache manager with global configuration \n{0}\nand default configuration:\n{1}",
       globalConfiguration, configuration);
   return new DefaultCacheManager(globalConfiguration, configuration);
 }
Пример #13
0
 @Test(expectedExceptions = CacheConfigurationException.class)
 public void testRecoveryAndAsyncCommitPhaseCaches() {
   // Note: this configuration uses Xa Enlistment (see configs/recovery-enabled-config.xml).
   Configuration defaultConfig = cacheManager.getDefaultCacheConfiguration();
   ConfigurationBuilder builder = new ConfigurationBuilder().read(defaultConfig);
   builder.clustering().cacheMode(CacheMode.REPL_SYNC);
   builder.transaction().syncCommitPhase(false).recovery().enable();
   // it should throw an exception when try to build this configuration.
   builder.build();
 }
  @Test
  public void testEnableStatistics() {
    Properties p = createProperties();
    p.setProperty("hibernate.cache.infinispan.statistics", "true");
    p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.lifespan", "60000");
    p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.max_idle", "30000");
    p.setProperty("hibernate.cache.infinispan.entity.cfg", "myentity-cache");
    p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
    p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
    p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
    InfinispanRegionFactory factory = createRegionFactory(p);
    try {
      EmbeddedCacheManager manager = factory.getCacheManager();
      assertTrue(manager.getCacheManagerConfiguration().globalJmxStatistics().enabled());
      EntityRegionImpl region =
          (EntityRegionImpl)
              factory.buildEntityRegion("com.acme.Address", p, MUTABLE_NON_VERSIONED);
      AdvancedCache cache = region.getCache();
      assertTrue(factory.getTypeOverrides().get("entity").isExposeStatistics());
      assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());

      region =
          (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, MUTABLE_NON_VERSIONED);
      cache = region.getCache();
      assertTrue(factory.getTypeOverrides().get("com.acme.Person").isExposeStatistics());
      assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());

      final String query = "org.hibernate.cache.internal.StandardQueryCache";
      QueryResultsRegionImpl queryRegion =
          (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
      cache = queryRegion.getCache();
      assertTrue(factory.getTypeOverrides().get("query").isExposeStatistics());
      assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());

      final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
      ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.clustering().stateTransfer().fetchInMemoryState(true);
      manager.defineConfiguration("timestamps", builder.build());
      TimestampsRegionImpl timestampsRegion =
          (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
      cache = timestampsRegion.getCache();
      assertTrue(factory.getTypeOverrides().get("timestamps").isExposeStatistics());
      assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());

      CollectionRegionImpl collectionRegion =
          (CollectionRegionImpl)
              factory.buildCollectionRegion("com.acme.Person.addresses", p, MUTABLE_NON_VERSIONED);
      cache = collectionRegion.getCache();
      assertTrue(factory.getTypeOverrides().get("collection").isExposeStatistics());
      assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
    } finally {
      factory.stop();
    }
  }
  public void testDefaultInterceptorStack() {
    assert TestingUtil.findInterceptor(cm.getCache(), MarshalledValueInterceptor.class) == null;

    ConfigurationBuilder configuration = new ConfigurationBuilder();
    configuration.storeAsBinary().enable();
    cm.defineConfiguration("someCache", configuration.build());
    Cache<?, ?> c = cm.getCache("someCache");

    assert TestingUtil.findInterceptor(c, MarshalledValueInterceptor.class) != null;
    TestingUtil.killCaches(c);
  }
  private EmbeddedCacheManager createCacheManagerProgrammatically() {
    System.out.println("####### Starting a cache manager with a programmatic configuration");

    GlobalConfigurationBuilder builder = new GlobalConfigurationBuilder();
    builder.nonClusteredDefault();
    ConfigurationBuilder cacheBuider = new ConfigurationBuilder();
    EmbeddedCacheManager cacheManager =
        new DefaultCacheManager(builder.build(), cacheBuider.build());

    return cacheManager;
  }
Пример #17
0
  private void removeRemoteIndexingInterceptorFromConfig(Configuration cfg) {
    ConfigurationBuilder builder = new ConfigurationBuilder();
    CustomInterceptorsConfigurationBuilder customInterceptorsBuilder = builder.customInterceptors();

    for (InterceptorConfiguration interceptorConfig : cfg.customInterceptors().interceptors()) {
      if (!(interceptorConfig.asyncInterceptor() instanceof RemoteValueWrapperInterceptor)) {
        customInterceptorsBuilder.addInterceptor().read(interceptorConfig);
      }
    }

    cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors());
  }
  @Test(expectedExceptions = IllegalArgumentException.class)
  public void numVirtualNodes() {
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.clustering().cacheMode(CacheMode.DIST_SYNC);
    cb.clustering().hash().numSegments(5);

    Configuration c = cb.build();
    Assert.assertEquals(5, c.clustering().hash().numSegments());

    // negative test
    cb.clustering().hash().numSegments(0);
  }
Пример #19
0
  private void removeQueryInterceptorFromConfiguration(Configuration cfg) {

    ConfigurationBuilder builder = new ConfigurationBuilder();
    CustomInterceptorsConfigurationBuilder customInterceptorsBuilder = builder.customInterceptors();

    for (InterceptorConfiguration interceptorConfig : cfg.customInterceptors().interceptors()) {
      if (!(interceptorConfig.interceptor() instanceof QueryInterceptor)) {
        customInterceptorsBuilder.addInterceptor().read(interceptorConfig);
      }
    }

    cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors());
  }
Пример #20
0
 @Test
 public void testCacheManager() {
   ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.transaction().invocationBatching().enable();
   EmbeddedCacheManager cm = new DefaultCacheManager(builder.build());
   Cache<String, String> cache = cm.getCache();
   TreeCacheFactory tcf = new TreeCacheFactory();
   TreeCache<String, String> tree = tcf.createTreeCache(cache);
   Fqn leafFqn = Fqn.fromElements("branch", "leaf");
   Node<String, String> leaf = tree.getRoot().addChild(leafFqn);
   leaf.put("fruit", "orange");
   cm.stop();
 }
 public void testMultipleCachesWithNoCacheName() {
   ConfigurationBuilder cb = new ConfigurationBuilder();
   cb.sites()
       .addBackup()
       .site("LON")
       .strategy(BackupConfiguration.BackupStrategy.SYNC)
       .sites()
       .addBackup()
       .site("SFO")
       .sites()
       .addBackup()
       .site("NYC");
   cb.build();
 }
Пример #22
0
  public void testAtomicMapWithoutBatchSet() {
    ConfigurationBuilder builder = buildConfiguration();
    builder.invocationBatching().disable();
    cacheManager.defineConfiguration("ahm_without_batch", builder.build());
    Cache<String, String> ahmCache = cacheManager.getCache("ahm_without_batch");

    AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(ahmCache, "key");
    assert map.isEmpty();
    map.put("a", "b");
    assert map.get("a").equals("b");

    // now re-retrieve the map and make sure we see the diffs
    assert AtomicMapLookup.getAtomicMap(ahmCache, "key").get("a").equals("b");
  }
 @Test(expectedExceptions = CacheConfigurationException.class)
 public void testSameBackupDefinedMultipleTimes() {
   ConfigurationBuilder cb = new ConfigurationBuilder();
   cb.sites()
       .addBackup()
       .site("LON")
       .strategy(BackupConfiguration.BackupStrategy.SYNC)
       .sites()
       .addBackup()
       .site("LON")
       .sites()
       .addBackup()
       .site("NYC");
   cb.build();
 }
 @Test(expected = CacheException.class)
 public void testTimestampValidation() {
   Properties p = createProperties();
   final DefaultCacheManager manager =
       new DefaultCacheManager(GlobalConfigurationBuilder.defaultClusteredBuilder().build());
   try {
     InfinispanRegionFactory factory = createRegionFactory(manager, p);
     ConfigurationBuilder builder = new ConfigurationBuilder();
     builder.clustering().cacheMode(CacheMode.INVALIDATION_SYNC);
     manager.defineConfiguration("timestamps", builder.build());
     factory.start(null, p);
     fail("Should have failed saying that invalidation is not allowed for timestamp caches.");
   } finally {
     TestingUtil.killCacheManagers(manager);
   }
 }
Пример #25
0
  @Test(expectedExceptions = IllegalStateException.class)
  public void testAtomicMapNonTransactionWithoutBatchSet() {
    ConfigurationBuilder builder = buildConfiguration();
    builder.invocationBatching().disable();
    builder.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL);
    cacheManager.defineConfiguration("ahm_no_tx_without_batch", builder.build());
    Cache<String, String> ahmCache = cacheManager.getCache("ahm_no_tx_without_batch");

    AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(ahmCache, "key");
    assert map.isEmpty();
    map.put("a", "b");
    assert map.get("a").equals("b");

    // now re-retrieve the map and make sure we see the diffs
    assert AtomicMapLookup.getAtomicMap(ahmCache, "key").get("a").equals("b");
  }
Пример #26
0
  public void testAtomicMapWithoutTransactionManagerLookupSet() {
    ConfigurationBuilder builder = buildConfiguration();
    builder
        .transaction()
        .transactionMode(TransactionMode.TRANSACTIONAL)
        .transactionManagerLookup(null);
    cacheManager.defineConfiguration("ahm_without_tmlookup", builder.build());
    Cache<String, String> ahmCache = cacheManager.getCache("ahm_without_tmlookup");

    AtomicMap<String, String> map = AtomicMapLookup.getAtomicMap(ahmCache, "key");
    assert map.isEmpty();
    map.put("a", "b");
    assert map.get("a").equals("b");

    // now re-retrieve the map and make sure we see the diffs
    assert AtomicMapLookup.getAtomicMap(ahmCache, "key").get("a").equals("b");
  }
Пример #27
0
  @BeforeClass
  public static void beforeclass() {
    GlobalConfigurationBuilder globalConfigurationBuilder =
        new GlobalConfigurationBuilder().nonClusteredDefault();
    globalConfigurationBuilder.globalJmxStatistics().jmxDomain("infinispan-" + UUID.randomUUID());

    ConfigurationBuilder cacheConfiguration = new ConfigurationBuilder();
    cacheConfiguration.dataContainer().keyEquivalence(new AnyServerEquivalence());

    serverCache = new DefaultCacheManager(globalConfigurationBuilder.build());
    serverCache.defineConfiguration("sessions", cacheConfiguration.build());

    HotRodServerConfigurationBuilder hotRodServerConfigurationBuilder =
        new HotRodServerConfigurationBuilder();
    hotRodServerConfigurationBuilder.port(RemoteConfiguration.SERVER_PORT);

    server = new HotRodServer();
    server.start(hotRodServerConfigurationBuilder.build(), serverCache);
  }
  @Override
  protected void createCacheManagers() throws Throwable {
    ConfigurationBuilder configuration = defaultRecoveryConfig();
    assert configuration.build().transaction().transactionMode().isTransactional();
    createCluster(configuration, 3);
    waitForClusterToForm();

    key = getKey();

    tm(2).begin();
    cache(2).put(this.key, "newValue");
    DummyTransaction tx = (DummyTransaction) tm(2).suspend();
    prepareTransaction(tx);

    killMember(2);

    assert !recoveryOps(0).showInDoubtTransactions().isEmpty();
    assert !recoveryOps(1).showInDoubtTransactions().isEmpty();
  }
Пример #29
0
  protected static EmbeddedCacheManager createCacheManager() throws Exception {
    GlobalConfigurationBuilder gcfg = new GlobalConfigurationBuilder();
    gcfg.globalJmxStatistics().allowDuplicateDomains(true);

    ConfigurationBuilder cfg = new ConfigurationBuilder();
    cfg.transaction()
        .transactionMode(TransactionMode.TRANSACTIONAL)
        .indexing()
        .index(Index.ALL)
        .addProperty("default.directory_provider", "ram")
        .addProperty(
            "error_handler",
            "org.infinispan.all.embeddedquery.testdomain.StaticTestingErrorHandler")
        .addProperty("lucene_version", "LUCENE_CURRENT");

    EmbeddedCacheManager cm = new DefaultCacheManager(gcfg.build(), cfg.build());

    return cm;
  }
Пример #30
0
  public org.infinispan.configuration.cache.Configuration build() {
    ConfigurationBuilder cb = new ConfigurationBuilder();
    if (c.isStoreByValue()) cb.storeAsBinary().enable();

    Factory<CacheLoader<K, V>> cacheLoaderFactory = c.getCacheLoaderFactory();
    if (cacheLoaderFactory != null) {
      // User-defined cache loader will be plugged once cache has started
      cb.persistence().addStore(JStoreAdapterConfigurationBuilder.class);
    }

    Factory<CacheWriter<? super K, ? super V>> cacheWriterFactory = c.getCacheWriterFactory();
    if (cacheWriterFactory != null) {
      // User-defined cache writer will be plugged once cache has started
      cb.persistence().addStore(JCacheWriterAdapterConfigurationBuilder.class);
    }

    if (c.isStatisticsEnabled()) cb.jmxStatistics().enable();

    return cb.build();
  }