当前位置: 首页>>代码示例>>Java>>正文


Java TransactionMode类代码示例

本文整理汇总了Java中org.infinispan.transaction.TransactionMode的典型用法代码示例。如果您正苦于以下问题:Java TransactionMode类的具体用法?Java TransactionMode怎么用?Java TransactionMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TransactionMode类属于org.infinispan.transaction包,在下文中一共展示了TransactionMode类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: defaultClusteredCacheManager

import org.infinispan.transaction.TransactionMode; //导入依赖的package包/类
@Produces
@ApplicationScoped
public EmbeddedCacheManager defaultClusteredCacheManager() {
    GlobalConfiguration g = new GlobalConfigurationBuilder()
            .clusteredDefault()
            .transport()
            .clusterName(MACHINE_TRANSLATIONS_CLUSTER)
            .globalJmxStatistics()
            .allowDuplicateDomains(true)
            .build();
    Configuration cfg = new ConfigurationBuilder()
            .clustering()
            .cacheMode(CacheMode.DIST_ASYNC)
            .eviction()
            .strategy(EvictionStrategy.LRU)
            .type(EvictionType.COUNT).size(150)
            .transaction()
            .transactionMode(TransactionMode.TRANSACTIONAL)
            .lockingMode(LockingMode.PESSIMISTIC)
            .build();
    return new DefaultCacheManager(g, cfg);
}
 
开发者ID:zanata,项目名称:zanata-mt,代码行数:23,代码来源:ResourceProducer.java

示例2: createCacheManagers

import org.infinispan.transaction.TransactionMode; //导入依赖的package包/类
@Override
public void createCacheManagers() throws Throwable {
    builderUsed = new ConfigurationBuilder();
    builderUsed.clustering().cacheMode(cacheMode);
    if (tx) {
        builderUsed.transaction().transactionMode(TransactionMode.TRANSACTIONAL);
    }
    if (cacheMode.isDistributed()) {
        builderUsed.clustering().hash().numOwners(1);
    }
    if (cacheName != null) {
        createClusteredCaches(clusterSize, cacheName, builderUsed);
    } else {
        createClusteredCaches(clusterSize, builderUsed);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:InfinispanClusterTestSupport.java

示例3: createContainerForLucene

import org.infinispan.transaction.TransactionMode; //导入依赖的package包/类
public static DefaultCacheManager createContainerForLucene()
		throws Exception {

    GlobalConfiguration glob = new GlobalConfigurationBuilder()
    .nonClusteredDefault() //Helper method that gets you a default constructed GlobalConfiguration, preconfigured for use in LOCAL mode
    .globalJmxStatistics().enable() //This method allows enables the jmx statistics of the global configuration.
   .jmxDomain("org.infinispan.trades.annotated." + ++cnt)  //prevent collision with non-transactional carmart
    .build(); //Builds  the GlobalConfiguration object
    Configuration loc = new ConfigurationBuilder()
	.indexing().enable().addProperty("hibernate.search.default.directory_provider", "filesystem").addProperty("hibernate.search.default.indexBase", "./target/lucene/indexes " + cnt)
    .clustering().cacheMode(CacheMode.LOCAL) //Set Cache mode to LOCAL - Data is not replicated.
    .transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL)
    .eviction().maxEntries(100).strategy(EvictionStrategy.LIRS) //Sets  4 as maximum number of entries in a cache instance and uses the LIRS strategy - an efficient low inter-reference recency set replacement policy to improve buffer cache performance
    .persistence().passivation(false).addSingleFileStore().purgeOnStartup(true).location("./target/localcache/indexing/trades" + cnt) //Disable passivation and adds a SingleFileStore that is purged on Startup
    .build(); //Builds the Configuration object
	DefaultCacheManager container = new DefaultCacheManager(glob, loc, true);

	return container;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:20,代码来源:TestInfinispanConnection.java

示例4: buildCacheManager

import org.infinispan.transaction.TransactionMode; //导入依赖的package包/类
private DefaultCacheManager buildCacheManager() {
    GlobalConfiguration glob = new GlobalConfigurationBuilder().clusteredDefault()

            //.transport().addProperty("configurationFile", System.getProperty("playground.jgroups.configuration", "default-jgroups-tcp.xml"))
            .transport().clusterName("PLAYGROUND")
            .globalJmxStatistics().allowDuplicateDomains(true).enable()
            .build();

    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
    configurationBuilder.jmxStatistics().enable();
    configureCacheMode(configurationBuilder);

    if (persistence()) {
        configureCacheStore(configurationBuilder);
    }

    Configuration loc = configurationBuilder.transaction().transactionMode(TransactionMode.TRANSACTIONAL).transactionManagerLookup(new DummyTransactionManagerLookup()).build();
    return new DefaultCacheManager(glob, loc, true);
}
 
开发者ID:redhat-italy,项目名称:jdg-quickstarts,代码行数:20,代码来源:PlaygroundConfiguration.java

示例5: transact

import org.infinispan.transaction.TransactionMode; //导入依赖的package包/类
void transact() {
    if (options.getBoolean(Caching.CreateOption.TRANSACTIONAL)) {
        LockingMode mode = LockingMode.valueOf(options.getString(Caching.CreateOption.LOCKING).toUpperCase());
        builder.transaction()
            .transactionMode(TransactionMode.TRANSACTIONAL)
            .transactionManagerLookup(TM_LOOKUP)
            .lockingMode(mode)
            .recovery()
            .versioning().enabled(mode==LockingMode.OPTIMISTIC).scheme(VersioningScheme.SIMPLE)
            .locking()
            .isolationLevel(mode==LockingMode.OPTIMISTIC ? IsolationLevel.REPEATABLE_READ : IsolationLevel.READ_COMMITTED)
            .writeSkewCheck(mode==LockingMode.OPTIMISTIC);
    } else {
        builder.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL);
    }
}
 
开发者ID:projectodd,项目名称:wunderboss,代码行数:17,代码来源:Config.java

示例6: main

import org.infinispan.transaction.TransactionMode; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
   // Define the default cache to be transactional
   ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL);
   // Construct a local cache manager using the configuration we have defined
   DefaultCacheManager cacheManager = new DefaultCacheManager(builder.build());
   // Obtain the default cache
   Cache<String, String> cache = cacheManager.getCache();
   // Obtain the transaction manager
   TransactionManager transactionManager = cache.getAdvancedCache().getTransactionManager();
   // Perform some operations within a transaction and commit it
   transactionManager.begin();
   cache.put("key1", "value1");
   cache.put("key2", "value2");
   transactionManager.commit();
   // Display the current cache contents
   System.out.printf("key1 = %s\nkey2 = %s\n", cache.get("key1"), cache.get("key2"));
   // Perform some operations within a transaction and roll it back
   transactionManager.begin();
   cache.put("key1", "value3");
   cache.put("key2", "value4");
   transactionManager.rollback();
   // Display the current cache contents
   System.out.printf("key1 = %s\nkey2 = %s\n", cache.get("key1"), cache.get("key2"));
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:28,代码来源:InfinispanTx.java

示例7: InfinispanCache

import org.infinispan.transaction.TransactionMode; //导入依赖的package包/类
public InfinispanCache(org.infinispan.Cache<K, V> cacheStore, String cacheName, ClassLoader classloader) {
	assert(cacheStore != null);
	this.cacheStore = cacheStore.getAdvancedCache();
	TransactionMode transactionMode = this.cacheStore.getCacheConfiguration().transaction().transactionMode();
	this.transactional = transactionMode == TransactionMode.TRANSACTIONAL;
	LogManager.logDetail(LogConstants.CTX_RUNTIME, "Added", transactionMode, "infinispan cache", cacheName); //$NON-NLS-1$ //$NON-NLS-2$
	this.name = cacheName;
	this.classloader = classloader;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:10,代码来源:InfinispanCache.java

示例8: openDatabase

import org.infinispan.transaction.TransactionMode; //导入依赖的package包/类
@Override
public synchronized CacheStore openDatabase(final String storeName) throws StorageException {
    
    final String fullCacheName = cacheNamePrefix + ":" + storeName;
    
    org.infinispan.configuration.cache.Configuration conf =
            manager.getCacheConfiguration(fullCacheName);
    
    if (null == conf) {
        defineStandardCacheConfig(fullCacheName);
    } else {
        log.info("Using existing config for cache {}; Titan configuration property {}.{} is ignored for this cache",
                new Object[] { fullCacheName, STORAGE_NAMESPACE, STORAGE_TRANSACTIONAL_KEY });
        log.debug("Existing config for cache {}: {}", fullCacheName, conf);
    }
    
    final InfinispanCacheStore newStore;
    final Cache<?,?> c = manager.getCache(fullCacheName);
    if (c.getCacheConfiguration().transaction().transactionMode().equals(TransactionMode.TRANSACTIONAL)) {
        newStore = new InfinispanCacheTransactionalStore(fullCacheName, storeName, manager);
    } else {
        newStore = new InfinispanCacheStore(fullCacheName, storeName, manager);
    }
    
    
    return newStore;
}
 
开发者ID:thinkaurelius,项目名称:titan-experimental,代码行数:28,代码来源:InfinispanCacheStoreManager.java

示例9: init

import org.infinispan.transaction.TransactionMode; //导入依赖的package包/类
@Override
public void init() {

    //
    // Configuration externalization
    //

    String jdgConfiguration = System.getProperty("playground.jdg.configuration");

    log.info("configuring the cache from " + jdgConfiguration);

    File jdgConfigurationFile = new File(jdgConfiguration);

    if (!jdgConfigurationFile.isFile() || !jdgConfigurationFile.canRead()) {

        throw new IllegalStateException(
                "the cache configuration file " + jdgConfiguration +
                        " does not exist or is not readable - was the PoC correctly configured?");
    }

    //
    // Configure and build the cache manager
    //

    GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();

    gcb.
            transport().
            defaultTransport().
            clusterName(CLUSTER_NAME).
            // the configuration file must be placed in $JBOSS_HOME/<profile>/configuration directory
            addProperty("configurationFile", jdgConfiguration).
            globalJmxStatistics().
            allowDuplicateDomains(true).
            enable();

    GlobalConfiguration gc = gcb.build();

    this.cacheManager = new DefaultCacheManager(gc);

    //
    // Configure and build the cache
    //

    ConfigurationBuilder ccb = new ConfigurationBuilder();

    ccb.
            clustering().
            cacheMode(CacheMode.DIST_SYNC).
            transaction().transactionMode(TransactionMode.TRANSACTIONAL).
            transactionManagerLookup(new GenericTransactionManagerLookup()).
            lockingMode(LockingMode.PESSIMISTIC).
            useSynchronization(true);

    Configuration cc = ccb.build();

    cacheManager.defineConfiguration(CACHE_NAME, cc);

    this.cache = cacheManager.getCache(CACHE_NAME);

    log.info(this + " initialized");
}
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:63,代码来源:JDGAccessServlet.java

示例10: defineStandardCacheConfig

import org.infinispan.transaction.TransactionMode; //导入依赖的package包/类
/**
     * Defines a new Infinispan cache using the supplied name. The cache
     * configuration is the manager's default cache configuration plus
     * transactions explicitly either enabled or disabled depending on whether
     * the {@code transactional} field is true or false.
     * <p>
     * <b>The named cache must not already exist.</b>
     * 
     * @param cachename the cache to define
     */
    private void defineStandardCacheConfig(String cachename) throws StorageException {

        ConfigurationBuilder cb = new ConfigurationBuilder();
        
        // This method should only be called for caches with no existing config
        Preconditions.checkArgument(null == manager.getCacheConfiguration(cachename));
        
        // Load default cache configuration
        cb.read(manager.getDefaultCacheConfiguration());
        
        if (transactional) {
            cb.transaction()
              .transactionMode(TransactionMode.TRANSACTIONAL)
              .transactionManagerLookup(txlookup)
              .lockingMode(lockmode)
              .autoCommit(false)
              .locking()
              .lockAcquisitionTimeout(lockAcquisitionTimeoutMS, TimeUnit.MILLISECONDS)
              .build();
        } else {
            cb.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL);
        }
        
        if (null != directory) {
            StoreConfigurationBuilder sb;
//            switch(storeImplementation) {
//                case FILE:
                    sb = cb.persistence()
                          .addSingleFileStore()
                          .preload(singleFileStorePreload)
                          .location(directory.getAbsolutePath());
//                    break;
//                case LEVELDB:
//                    sb = cb.persistence()
//                            .addStore(LevelDBStoreConfigurationBuilder.class)
//                            .preload(singleFileStorePreload)
//                            .location(directory.getAbsolutePath() + File.separator + "data")
//                            .expiredLocation(directory.getAbsolutePath() + File.separator + "expired")
//                            .compressionType(CompressionType.SNAPPY);
//                    break;
//                default: throw new IllegalArgumentException("Unknown store implementation: " + storeImplementation);
//            }

            AsyncStoreConfigurationBuilder ab = sb.async().enabled(singleFileStoreAsync);
            if (singleFileStoreAsync) {
                ab.flushLockTimeout(3,TimeUnit.SECONDS)
                  .threadPoolSize(2)
                  .modificationQueueSize(10000)
                  .shutdownTimeout(30,TimeUnit.SECONDS);
            }
        }
        
        manager.defineConfiguration(cachename, cb.build());
        
        log.info("Defined transactional={} configuration for cache {}", transactional, cachename);
    }
 
开发者ID:thinkaurelius,项目名称:titan-experimental,代码行数:67,代码来源:InfinispanCacheStoreManager.java

示例11: cacheConfigurer

import org.infinispan.transaction.TransactionMode; //导入依赖的package包/类
/**
 * Initialize cache configuration for Hibernate L2 cache and Spring Cache.
 * <p>
 * There are three different modes: local, distributed and replicated, and L2 cache options are pre-configured.
 *
 * <p>
 * It supports both jCache and Spring cache abstractions.
 * <p>
 * Usage:
 *  <ol>
 *      <li>
 *          jCache:
 *          <pre class="code">@CacheResult(cacheName="dist-app-data") </pre>
 *              - for creating a distributed cache. In a similar way other cache names and options can be used
 *      </li>
 *      <li>
 *          Spring Cache:
 *          <pre class="code">@Cacheable(value = "repl-app-data") </pre>
 *              - for creating a replicated cache. In a similar way other cache names and options can be used
 *      </li>
 *      <li>
 *          Cache manager can also be injected through DI/CDI and data can be manipulated using Infinispan APIs,
 *          <pre class="code">
 *          &#064;Autowired (or) &#064;Inject
 *          private EmbeddedCacheManager cacheManager;
 *
 *          void cacheSample(){
 *              cacheManager.getCache("dist-app-data").put("hi", "there");
 *          }
 *          </pre>
 *      </li>
 *  </ol>
 *
 */
@Bean
public InfinispanCacheConfigurer cacheConfigurer(JHipsterProperties jHipsterProperties) {
    log.info("Defining {} configuration", "app-data for local, replicated and distributed modes");
    final JHipsterProperties.Cache.Infinispan cacheInfo = jHipsterProperties.getCache().getInfinispan();

    return manager -> {
        // initialize application cache
        manager.defineConfiguration("local-app-data", new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL)
            .jmxStatistics().enabled(cacheInfo.isStatsEnabled())
            .eviction().type(EvictionType.COUNT).size(cacheInfo.getLocal().getMaxEntries()).expiration()
            .lifespan(cacheInfo.getLocal().getTimeToLiveSeconds(), TimeUnit.MINUTES).build());
        manager.defineConfiguration("dist-app-data", new ConfigurationBuilder()
            .clustering().cacheMode(CacheMode.DIST_SYNC).hash().numOwners(cacheInfo.getDistributed().getInstanceCount())
            .jmxStatistics().enabled(cacheInfo.isStatsEnabled()).eviction()
            .type(EvictionType.COUNT).size(cacheInfo.getDistributed().getMaxEntries()).expiration().lifespan(cacheInfo.getDistributed()
            .getTimeToLiveSeconds(), TimeUnit.MINUTES).build());
        manager.defineConfiguration("repl-app-data", new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_SYNC)
            .jmxStatistics().enabled(cacheInfo.isStatsEnabled())
            .eviction().type(EvictionType.COUNT).size(cacheInfo.getReplicated()
            .getMaxEntries()).expiration().lifespan(cacheInfo.getReplicated().getTimeToLiveSeconds(), TimeUnit.MINUTES).build());

        // initialize Hibernate L2 cache
        manager.defineConfiguration("entity", new ConfigurationBuilder().clustering().cacheMode(CacheMode.INVALIDATION_SYNC)
            .jmxStatistics().enabled(cacheInfo.isStatsEnabled())
            .locking().concurrencyLevel(1000).lockAcquisitionTimeout(15000).build());
        manager.defineConfiguration("replicated-entity", new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_SYNC)
            .jmxStatistics().enabled(cacheInfo.isStatsEnabled())
            .locking().concurrencyLevel(1000).lockAcquisitionTimeout(15000).build());
        manager.defineConfiguration("local-query", new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL)
            .jmxStatistics().enabled(cacheInfo.isStatsEnabled())
            .locking().concurrencyLevel(1000).lockAcquisitionTimeout(15000).build());
        manager.defineConfiguration("replicated-query", new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_ASYNC)
            .jmxStatistics().enabled(cacheInfo.isStatsEnabled())
            .locking().concurrencyLevel(1000).lockAcquisitionTimeout(15000).build());
        manager.defineConfiguration("timestamps", new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_ASYNC)
            .jmxStatistics().enabled(cacheInfo.isStatsEnabled())
            .locking().concurrencyLevel(1000).lockAcquisitionTimeout(15000).build());
        manager.defineConfiguration("pending-puts", new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL)
            .jmxStatistics().enabled(cacheInfo.isStatsEnabled())
            .simpleCache(true).transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL).expiration().maxIdle(60000).build());

        setCacheManager(manager);
    };
}
 
开发者ID:jhipster,项目名称:generator-jhipster,代码行数:79,代码来源:_CacheConfiguration.java


注:本文中的org.infinispan.transaction.TransactionMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。