@Override protected EmbeddedCacheManager createCacheManager() throws Exception { GlobalConfigurationBuilder lonGc = GlobalConfigurationBuilder.defaultClusteredBuilder(); lonGc.site().localSite("LON"); ConfigurationBuilder lon = getDefaultClusteredCacheConfig(CacheMode.LOCAL, false); lon.sites().addBackup().site("NYC").strategy(BackupConfiguration.BackupStrategy.SYNC); nycBackup = getDefaultClusteredCacheConfig(CacheMode.LOCAL, false); nycBackup.sites().backupFor().remoteSite("NYC").defaultRemoteCache(); // Remember to not do nothing else other than // creating the cache manager in order to avoid leaks return TestCacheManagerFactory.createClusteredCacheManager(lonGc, lon); }
@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); } }
public static List createTopologyAwareCacheNodes( int numberOfNodes, CacheMode cacheMode, boolean transactional, boolean indexLocalOnly, boolean isRamDirectoryProvider) { List caches = new ArrayList(); ConfigurationBuilder builder = AbstractCacheTest.getDefaultClusteredCacheConfig(cacheMode, transactional); builder.indexing().enable().indexLocalOnly(indexLocalOnly); if (isRamDirectoryProvider) { builder .indexing() .addProperty("default.directory_provider", "ram") .addProperty("lucene_version", "LUCENE_CURRENT"); } else { builder .indexing() .addProperty( "hibernate.search.default.indexmanager", "org.infinispan.query.indexmanager.InfinispanIndexManager") .addProperty("default.directory_provider", "infinispan") .addProperty("hibernate.search.default.exclusive_index_use", "false") .addProperty("lucene_version", "LUCENE_36"); if (cacheMode.isClustered()) { builder.clustering().stateTransfer().fetchInMemoryState(true); } } for (int i = 0; i < numberOfNodes; i++) { GlobalConfigurationBuilder globalConfigurationBuilder = GlobalConfigurationBuilder.defaultClusteredBuilder(); globalConfigurationBuilder.transport().machineId("a" + i).rackId("b" + i).siteId("test" + i); EmbeddedCacheManager cm1 = TestCacheManagerFactory.createClusteredCacheManager(globalConfigurationBuilder, builder); caches.add(cm1.getCache()); } return caches; }
@Override protected void createCacheManagers() throws Throwable { final GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder(); final ConfigurationBuilder builder = getDefaultClusteredCacheConfig(getCacheMode()); global .security() .authorization() .enable() .principalRoleMapper(new IdentityRoleMapper()) .role("admin") .permission(AuthorizationPermission.ALL); builder.security().authorization().enable().role("admin"); Security.doAs( ADMIN, new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { createCluster(global, builder, 2); waitForClusterToForm(); return null; } }); }