@Override public void accept(SingleFileStoreConfigurationBuilder builder) { builder.location(this.pathManager.get().resolveRelativePathEntry(this.relativePath, this.relativeTo)); } }
persistConfig.passivation(false); final SingleFileStoreConfigurationBuilder fileStore = new SingleFileStoreConfigurationBuilder(persistConfig).location(location); fileStore.invocationBatching().enable(); fileStore.eviction().maxEntries(15);
@Override public void accept(SingleFileStoreConfigurationBuilder builder) { builder.location(this.pathManager.get().resolveRelativePathEntry(this.relativePath, this.relativeTo)); } }
@Override public void inject(PathManager value) { callbackHandle = value.registerCallback(relativeTo, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED); builder.location(value.resolveRelativePathEntry(path, relativeTo)); }
void persist() { Object v = options.get(Caching.CreateOption.PERSIST); if (v instanceof Boolean && (boolean) v) { builder.persistence().addSingleFileStore(); } if (v instanceof String) { builder.persistence().addSingleFileStore().location(v.toString()); } }
@Override protected PersistenceConfigurationBuilder createCacheStoreConfig(PersistenceConfigurationBuilder persistence, boolean preload) { persistence .addSingleFileStore() .location(tmpDirectory) .preload(preload); return persistence; }
protected void addCacheStoreConfig(ConfigurationBuilder builder, int index) { builder.persistence().addSingleFileStore().location(tmpDirectory + "/" + index); }
@Override protected void configurePersistence(ConfigurationBuilder cb) { location = TestingUtil.tmpDirectory(this.getClass()); cb.persistence().addStore(SingleFileStoreConfigurationBuilder.class).location(location); }
@Override protected void configure(ConfigurationBuilder config) { config // Prevent the reaper from running, reaperEnabled(false) doesn't work when a store is present .expiration().wakeUpInterval(Long.MAX_VALUE) .persistence().addSingleFileStore().location(TestingUtil.tmpDirectory(this.getClass())); }
@Override protected void configure(ConfigurationBuilder config) { config // Prevent the reaper from running, reaperEnabled(false) doesn't work when a store is present .expiration().wakeUpInterval(Long.MAX_VALUE) .clustering().cacheMode(CacheMode.DIST_SYNC) .persistence().addSingleFileStore().location(TestingUtil.tmpDirectory(this.getClass())); }
private CacheContainer createCacheContainerWithStore(String location) { ConfigurationBuilder b = new ConfigurationBuilder(); b.persistence().addSingleFileStore().location(location); CacheContainer cc = TestCacheManagerFactory.createCacheManager(b); TestingUtil.replaceComponent(cc, TimeService.class, timeService, true); return cc; }
@Override protected EmbeddedCacheManager createCacheManager(ConfigurationBuilder builder) { extraManager = TestCacheManagerFactory.createClusteredCacheManager(builder); // Inject our time service into the new CacheManager as well TestingUtil.replaceComponent(extraManager, TimeService.class, timeService, true); extraCache = extraManager.getCache(); SingleFileStoreConfigurationBuilder sfsBuilder = (SingleFileStoreConfigurationBuilder) builder.persistence().stores().get(0); // Make sure each cache writes to a different location sfsBuilder.location(TestingUtil.tmpDirectory(this.getClass().getSimpleName() + "2")); EmbeddedCacheManager returned = TestCacheManagerFactory.createClusteredCacheManager(builder); // Unfortunately we can't reinject timeservice once a cache has been started, thus we have to inject // here as well, since we need the cache to verify the cluster was formed TestingUtil.replaceComponent(returned, TimeService.class, timeService, true); Cache<Object, Object> checkCache = returned.getCache(); TestingUtil.blockUntilViewReceived(checkCache, 2, TimeUnit.SECONDS.toMillis(10)); return returned; } }
@BeforeMethod public void setUp() throws Exception { clearTempDir(); store = new SingleFileStore(); ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); builder .persistence() .addStore(SingleFileStoreConfigurationBuilder.class) .location(this.tmpDirectory) .maxEntries(1); marshaller = new TestObjectStreamMarshaller(); store.init(PersistenceMockUtil.createContext(getClass().getSimpleName(), builder.build(), marshaller)); store.start(); }
private void createStatefulCacheManager(String id, boolean clear) { String stateDirectory = TestingUtil.tmpDirectory(this.getClass().getSimpleName() + File.separator + id); if (clear) Util.recursiveFileRemove(stateDirectory); GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder(); global.globalState().enable().persistentLocation(stateDirectory); ConfigurationBuilder config = new ConfigurationBuilder(); applyCacheManagerClusteringConfiguration(config); config.persistence().addSingleFileStore().location(stateDirectory); addClusterEnabledCacheManager(global, config); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { location = TestingUtil.tmpDirectory(SingleFileStoreStressTest.class); ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addSingleFileStore().location(this.location).purgeOnStartup(true); EmbeddedCacheManager cacheManager = TestCacheManagerFactory.createCacheManager(builder); cacheManager.defineConfiguration(CACHE_NAME, builder.build()); return cacheManager; }
private void enableTestJdbcStorage(ConfigurationBuilder configuration) throws Exception { configuration .persistence() .passivation(false) .addSingleFileStore() .preload(false) .shared(false) .location(tmpDirectory) .async() .enable() .threadPoolSize(1); }
@Override protected void createCacheManagers() throws Throwable { Util.recursiveFileRemove(tmpDirectory); ConfigurationBuilder cfg = TestCacheManagerFactory.getDefaultCacheConfiguration(true); cfg.persistence() .addStore(SingleFileStoreConfigurationBuilder.class) .location(tmpDirectory); // ensure the data container contains minimal data so the store will need to be accessed to get the rest cfg.locking().concurrencyLevel(1).dataContainer().memory().size(1L); createClusteredCaches(1, cfg); } }
@Override protected AdvancedLoadWriteStore createStore() { clearTempDir(); SingleFileStore store = new SingleFileStore(); ConfigurationBuilder configurationBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false); configurationBuilder .persistence() .addStore(SingleFileStoreConfigurationBuilder.class) .location(this.tmpDirectory) .memory() .storageType(storage); store.init(createContext(configurationBuilder.build())); return store; } }
protected EmbeddedCacheManager createCacheManager(int maxEntries) throws Exception { return new DefaultCacheManager( new GlobalConfigurationBuilder().build(), new ConfigurationBuilder() .memory().evictionType(EvictionType.COUNT).size(maxEntries) .persistence().passivation(true) .addSingleFileStore().location(storeDir.getAbsolutePath()).preload(true) .indexing().index(Index.ALL) .addIndexedEntity(Person.class) .addIndexedEntity(Car.class) .addProperty("default.directory_provider", "filesystem") .addProperty("default.indexBase", indexDir.getAbsolutePath()) .addProperty("lucene_version", "LUCENE_CURRENT") .build() ); }
public void testDocumentationPersistenceConfiguration() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence() .passivation(false) .addSingleFileStore() .fetchPersistentState(true) .shared(false) .preload(true) .ignoreModifications(false) .purgeOnStartup(false) .location(System.getProperty("java.io.tmpdir")) .async() .enabled(true) .flushLockTimeout(15000) .threadPoolSize(5) .singleton() .enabled(true) .pushStateWhenCoordinator(true) .pushStateTimeout(20000); }