@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); fileStore.eviction().strategy(EvictionStrategy.LRU); fileStore.jmxStatistics().disable(); final Configuration config = persistConfig.addStore(fileStore).build(); config.compatibility().enabled();
@Override public AsyncStoreConfiguration get() { return new ConfigurationBuilder().persistence().addSingleFileStore().async().disable().create(); } }
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); }
private void parseSingleFileStore(XMLExtendedStreamReader reader, ConfigurationBuilderHolder holder) throws XMLStreamException { ConfigurationBuilder builder = holder.getCurrentConfigurationBuilder(); SingleFileStoreConfigurationBuilder storeBuilder = builder.persistence().addSingleFileStore(); for (int i = 0; i < reader.getAttributeCount(); i++) { ParseUtils.requireNoNamespaceAttribute(reader, i); String value = replaceProperties(reader.getAttributeValue(i)); String attrName = reader.getAttributeLocalName(i); Attribute attribute = Attribute.forName(attrName); switch (attribute) { case LOCATION: storeBuilder.location(value); break; case MAX_ENTRIES: storeBuilder.maxEntries(Integer.parseInt(value)); break; default: parseCommonStoreAttributes(reader, storeBuilder, attrName, value, i); break; } } parseStoreChildren(reader, storeBuilder); }
private EmbeddedCacheManager getCacheManager(boolean batchingEnabled) throws Exception { ConfigurationBuilder builder = new ConfigurationBuilder(); builder .persistence() .passivation(false) .addSingleFileStore() .location(TMP_DIR + File.separator + "cacheStore") .preload(false) .fetchPersistentState(true) .purgeOnStartup(false) .indexing() .index(Index.PRIMARY_OWNER) .addIndexedEntity(SEntity.class) .addProperty("default.directory_provider", "filesystem") .addProperty("lucene_version", "LUCENE_CURRENT") .addProperty("default.indexBase", TMP_DIR + File.separator + "idx"); if (batchingEnabled) { builder.invocationBatching().enable(); } else { builder.invocationBatching().disable(); } return TestCacheManagerFactory.createCacheManager(builder); }
public void testStateTransfer() throws Exception { final int numKeys = 300; for (int i = 0; i < numKeys; i++) { cache(0).put(i, i); } log.info("Finished putting keys"); for (int i = 0; i < numKeys; i++) { assertEquals(i, cache(0).get(i)); } log.info("Adding a new node .."); builder.persistence().clearStores().addSingleFileStore().location(new File(tmpDir, "store1").getAbsolutePath()) // make sure this node writes in a different location .fetchPersistentState(true) .ignoreModifications(false) .purgeOnStartup(false); addClusterEnabledCacheManager(builder); log.info("Added a new node"); for (int i = 0; i < numKeys; i++) { assertEquals(i, cache(1).get(i)); // some keys are lost in 5.2 } } }
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() ); }
@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; }
case SINGLE_FILE_STORE: props.required(LOCATION); return new SingleFileStoreConfigurationBuilder(persistenceBuilder).location(props.get(LOCATION)); case SOFT_INDEX_FILE_STORE: props.required(LOCATION);
@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; } }
public MetadataManager(DefaultCacheManager cacheManager){ Configuration cacheConfiguration = cacheManager.getCacheConfiguration(Support.AVRO_METADATA_CACHE_NAME); if (cacheConfiguration == null) { ConfigurationBuilder cfg = new ConfigurationBuilder(); CacheMode cacheMode = cacheManager.getDefaultCacheConfiguration().clustering().cacheMode().equals(CacheMode.LOCAL) ? CacheMode.LOCAL : CacheMode.REPL_SYNC; cfg .transaction().lockingMode(LockingMode.PESSIMISTIC).syncCommitPhase(true).syncRollbackPhase(true) .persistence().addSingleFileStore().location(System.getProperty("java.io.tmpdir") + "/" + cacheManager.getNodeAddress()) // mandatory .locking().isolationLevel(IsolationLevel.READ_COMMITTED).useLockStriping(false) .clustering().cacheMode(cacheMode) .stateTransfer().fetchInMemoryState(true) .dataContainer().keyEquivalence(new ByteArrayEquivalence()); // for HotRod compatibility if (cacheMode.equals(CacheMode.REPL_SYNC)) cfg.clustering().stateTransfer().awaitInitialTransfer(true); cacheManager.defineConfiguration(Support.AVRO_METADATA_CACHE_NAME, cfg.build()); this.cacheManager = cacheManager; this.marshaller= Externalizer.getInstance(); this.knownSchemas = new ConcurrentHashMap<>(); knownSchemas.put(Request.getClassSchema().getFullName(), Request.getClassSchema()); knownSchemas.put(Response.getClassSchema().getFullName(), Response.getClassSchema()); } }
final SingleFileStoreConfigurationBuilder builder = persistenceBuilder.addStore(SingleFileStoreConfigurationBuilder.class); if (store.hasDefined(ModelKeys.MAX_ENTRIES)) { builder.maxEntries(store.get(ModelKeys.MAX_ENTRIES).asInt());
@Override protected void createCacheManagers() { tmpDir = new File(TestingUtil.tmpDirectory(this.getClass())); Util.recursiveFileRemove(tmpDir); // reproduce the MODE-1754 config as closely as possible builder = getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, true, true); builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL).lockingMode(LockingMode.PESSIMISTIC) .transactionManagerLookup(new EmbeddedTransactionManagerLookup()) .memory().size(1000) .locking().lockAcquisitionTimeout(20000) .concurrencyLevel(5000) // lowering this to 50 makes the test pass also on 5.2 but it's just a temporary workaround .useLockStriping(false).isolationLevel(IsolationLevel.READ_COMMITTED) .dataContainer().storeAsBinary() .clustering().remoteTimeout(20000) .stateTransfer().timeout(240000).fetchInMemoryState(false).chunkSize(10000) .persistence().passivation(false).addSingleFileStore().location(new File(tmpDir, "store0").getAbsolutePath()).shared(false).preload(false) .fetchPersistentState(true) .ignoreModifications(false) .purgeOnStartup(false); createCluster(builder, 1); waitForClusterToForm(); }
@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(); }
@Override public void accept(SingleFileStoreConfigurationBuilder builder) { builder.location(this.pathManager.get().resolveRelativePathEntry(this.relativePath, this.relativeTo)); } }
sfBuilder.location(location); if (level2MaxEntries > 0) { sfBuilder.maxEntries(level2MaxEntries);