org.infinispan.configuration.cache.Configuration.persistence()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中org.infinispan.configuration.cache.Configuration.persistence()方法的一些代码示例,展示了Configuration.persistence()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.persistence()方法的具体详情如下:
包路径:org.infinispan.configuration.cache.Configuration
类名称:Configuration
方法名:persistence

Configuration.persistence介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

public InfinispanCacheProperties(Configuration config) {
  this.transactional = config.transaction().transactionMode().isTransactional();
  this.lockOnWrite = this.transactional && (config.transaction().lockingMode() == LockingMode.PESSIMISTIC);
  this.lockOnRead = this.lockOnWrite && (config.locking().isolationLevel() == IsolationLevel.REPEATABLE_READ);
  boolean clustered = config.clustering().cacheMode().needsStateTransfer();
  boolean hasStore = config.persistence().usingStores();
  this.marshalling = clustered || hasStore;
  this.persistent = clustered || (hasStore && !config.persistence().passivation());
}

代码示例来源:origin: org.infinispan/infinispan-core

private static <T> T getStoreConfiguration(Configuration c, Class<T> configurationClass) {
 for (StoreConfiguration pc: c.persistence().stores()) {
   if (configurationClass.isInstance(pc)) {
    return (T) pc;
   }
 }
 throw new NoSuchElementException("There is no store of type " + configurationClass);
}

代码示例来源:origin: org.infinispan/infinispan-cachestore-remote

private StoreConfiguration buildCacheManagerWithCacheStore(final String config) throws IOException {
   InputStream is = new ByteArrayInputStream(config.getBytes());
   cacheManager = TestCacheManagerFactory.fromStream(is);
   assert cacheManager.getDefaultCacheConfiguration().persistence().stores().size() == 1;
   return cacheManager.getDefaultCacheConfiguration().persistence().stores().get(0);
  }
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

private static void validateMetadataCache(Cache<?, ?> cache, String indexName) {
 Configuration configuration = cache.getCacheConfiguration();
 if (configuration.memory().isEvictionEnabled()) {
   throw log.evictionNotAllowedInMetadataCache(indexName, cache.getName());
 }
 if (configuration.persistence().usingStores() && !configuration.persistence().preload()) {
   throw log.preloadNeededIfPersistenceIsEnabledForMetadataCache(indexName, cache.getName());
 }
}

代码示例来源:origin: org.infinispan/infinispan-lucene-directory

private static void validateMetadataCache(Cache<?, ?> cache, String indexName) {
 Configuration configuration = cache.getCacheConfiguration();
 if (configuration.memory().isEvictionEnabled()) {
   throw log.evictionNotAllowedInMetadataCache(indexName, cache.getName());
 }
 if (configuration.persistence().usingStores() && !configuration.persistence().preload()) {
   throw log.preloadNeededIfPersistenceIsEnabledForMetadataCache(indexName, cache.getName());
 }
}

代码示例来源:origin: org.infinispan/infinispan-adaptor52x

public void testLoaders() {
   List<StoreConfiguration> stores = cacheManager.getCache("customLoaderCache").getCacheConfiguration().persistence().stores();
   assertEquals(stores.size(), 1);
   StoreConfiguration storeConfiguration = stores.get(0);
   assertTrue(storeConfiguration instanceof ClusterLoaderConfiguration);
   ClusterLoaderConfiguration csc = (ClusterLoaderConfiguration) storeConfiguration;
   assertEquals(csc.remoteCallTimeout(), 1222);
  }
}

代码示例来源:origin: org.infinispan/infinispan-adaptor52x

public void testConfiguration() {
   Cache<Object,Object> customLoaderCache = cacheManager.getCache("customLoaderCache");
   List<StoreConfiguration> loaders = customLoaderCache.getCacheConfiguration().persistence().stores();
   assertEquals(loaders.size(), 1);

  }
}

代码示例来源:origin: org.jboss.eap/wildfly-clustering-ee-infinispan

public InfinispanCacheProperties(Configuration config) {
  this.transactional = config.transaction().transactionMode().isTransactional();
  this.lockOnWrite = this.transactional && (config.transaction().lockingMode() == LockingMode.PESSIMISTIC);
  this.lockOnRead = this.lockOnWrite && (config.locking().isolationLevel() == IsolationLevel.REPEATABLE_READ);
  boolean clustered = config.clustering().cacheMode().needsStateTransfer();
  boolean hasStore = config.persistence().usingStores();
  this.marshalling = clustered || hasStore;
  this.persistent = clustered || (hasStore && !config.persistence().passivation());
}

代码示例来源:origin: org.wildfly/wildfly-clustering-ee-infinispan

public InfinispanCacheProperties(Configuration config) {
  this.transactional = config.transaction().transactionMode().isTransactional();
  this.lockOnWrite = this.transactional && (config.transaction().lockingMode() == LockingMode.PESSIMISTIC);
  this.lockOnRead = this.lockOnWrite && (config.locking().isolationLevel() == IsolationLevel.REPEATABLE_READ);
  boolean clustered = config.clustering().cacheMode().needsStateTransfer();
  boolean hasStore = config.persistence().usingStores();
  this.marshalling = clustered || hasStore;
  this.persistent = clustered || (hasStore && !config.persistence().passivation());
}

代码示例来源:origin: org.infinispan/infinispan-core

public static <K, V> CacheLoader<K, V> getCacheLoader(Cache<K, V> cache) {
 if (cache.getCacheConfiguration().persistence().usingStores()) {
   return TestingUtil.getFirstLoader(cache);
 } else {
   return null;
 }
}

代码示例来源:origin: org.infinispan/infinispan-core

@Test
public void testClearStores() {
 Configuration c = new ConfigurationBuilder()
    .persistence()
      .addStore(DummyInMemoryStoreConfigurationBuilder.class)
    .persistence()
      .clearStores()
   .build();
 assertEquals(c.persistence().stores().size(), 0);
}

代码示例来源:origin: org.infinispan/infinispan-core

@Override
  public void call() {
   PersistenceConfiguration cfg = cm.getDefaultCacheConfiguration().persistence();
   StoreConfiguration config = cfg.stores().get(0);
   assertTrue(config instanceof DummyInMemoryStoreConfiguration);
   DummyInMemoryStoreConfiguration dummyInMemoryStoreConfiguration = (DummyInMemoryStoreConfiguration)config;
   assertEquals("myStore", dummyInMemoryStoreConfiguration.storeName());
  }
});

代码示例来源:origin: org.infinispan/infinispan-core

@Override
  public void call() {
   PersistenceConfiguration cfg = cm.getDefaultCacheConfiguration().persistence();
   StoreConfiguration config = cfg.stores().get(0);
   assertTrue(config instanceof AbstractStoreConfiguration);
   AbstractStoreConfiguration abstractStoreConfiguration = (AbstractStoreConfiguration)config;
   assertTrue(abstractStoreConfiguration.fetchPersistentState());
   assertTrue(abstractStoreConfiguration.preload());
  }
});

代码示例来源:origin: org.infinispan/infinispan-core

@Override
  public void check(ConfigurationBuilderHolder holder) {
   Configuration local = getConfiguration(holder, "local");
   PersistenceConfiguration persistenceConfiguration = local.persistence();
   assertEquals(5, persistenceConfiguration.connectionAttempts());
   assertEquals(100, persistenceConfiguration.connectionInterval());
   assertEquals(2000, persistenceConfiguration.availabilityInterval());
   assertFalse(persistenceConfiguration.stores().isEmpty());
   AsyncStoreConfiguration asyncConfig = persistenceConfiguration.stores().iterator().next().async();
   assertTrue(asyncConfig.failSilently());
  }
},

代码示例来源:origin: org.infinispan/infinispan-cachestore-jdbc

public void testImplicitPooledConnectionFactory() {
 ConfigurationBuilder b = new ConfigurationBuilder();
 b.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class)
   .connectionPool().connectionUrl(JDBC_URL);
 Configuration configuration = b.build();
 JdbcStringBasedStoreConfiguration store = (JdbcStringBasedStoreConfiguration) configuration.persistence().stores().get(0);
 assert store.connectionFactory() instanceof PooledConnectionFactoryConfiguration;
}

代码示例来源:origin: org.infinispan/infinispan-core

public static InitializationContext createContext(String nodeName, Configuration configuration, StreamingMarshaller marshaller, TimeService timeService) {
 Cache mockCache = mockCache(nodeName, configuration, timeService);
 return new InitializationContextImpl(configuration.persistence().stores().get(0), mockCache,
                    SingleSegmentKeyPartitioner.getInstance(), marshaller,
                    timeService, new ByteBufferFactoryImpl(), new MarshalledEntryFactoryImpl(marshaller),
                    new WithinThreadExecutor());
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testOverrideWithStore() {
 final ConfigurationBuilder builder1 = new ConfigurationBuilder();
 builder1.persistence().addStore(DummyInMemoryStoreConfigurationBuilder.class);
 cm = TestCacheManagerFactory.createCacheManager(builder1);
 ConfigurationBuilder builder2 = new ConfigurationBuilder();
 builder2.read(cm.getDefaultCacheConfiguration());
 builder2.memory().size(1000);
 Configuration configuration = cm.defineConfiguration("named", builder2.build());
 assertEquals(1, configuration.persistence().stores().size());
}

代码示例来源:origin: org.infinispan/infinispan-core

@SuppressWarnings("unchecked")
@Override
protected void initializeKeyAndCheckData(Object key, Object value) {
 assertTrue("A cache store should be configured!", cache.getCacheConfiguration().persistence().usingStores());
 cache.put(key, value);
 DataContainer container = cache.getAdvancedCache().getDataContainer();
 InternalCacheEntry entry = container.get(key);
 CacheLoader<Object, Object> loader = TestingUtil.getFirstLoader(cache);
 assertNotNull("Key " + key + " does not exist in data container.", entry);
 assertEquals("Wrong value for key " + key + " in data container.", value, entry.getValue());
 MarshalledEntry<Object, Object> entryLoaded = loader.load(key);
 assertNull("Key " + key + " exists in cache loader.", entryLoaded);
}

代码示例来源:origin: org.infinispan/infinispan-core

@SuppressWarnings("unchecked")
@Override
protected void initializeKeyAndCheckData(Object key, Object value) {
 assertTrue("A cache store should be configured!", cache.getCacheConfiguration().persistence().usingStores());
 cache.put(key, value);
 DataContainer container = cache.getAdvancedCache().getDataContainer();
 InternalCacheEntry entry = container.get(key);
 CacheLoader<Object, Object> loader = TestingUtil.getFirstLoader(cache);
 assertNotNull("Key " + key + " does not exist in data container.", entry);
 assertEquals("Wrong value for key " + key + " in data container.", value, entry.getValue());
 MarshalledEntry<Object, Object> entryLoaded = loader.load(key);
 assertNull("Key " + key + " exists in cache loader.", entryLoaded);
}

代码示例来源:origin: org.infinispan/infinispan-core

@SuppressWarnings("unchecked")
protected void initializeKeyAndCheckData(Object key, Object value) {
 assertTrue("A cache store should be configured!", cache.getCacheConfiguration().persistence().usingStores());
 cache.put(key, value);
 DataContainer container = cache.getAdvancedCache().getDataContainer();
 InternalCacheEntry entry = container.get(key);
 CacheLoader<Object, Object> loader = TestingUtil.getFirstLoader(cache);
 assertNotNull("Key " + key + " does not exist in data container.", entry);
 assertEquals("Wrong value for key " + key + " in data container.", value, entry.getValue());
 MarshalledEntry<Object, Object> entryLoaded = loader.load(key);
 assertNotNull("Key " + key + " does not exist in cache loader.", entryLoaded);
 assertEquals("Wrong value for key " + key + " in cache loader.", value, entryLoaded.getValue());
}

相关文章