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

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

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

Configuration.locking介绍

暂无

代码示例

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

private static List<Duration> calculateRetryIntervals(Configuration config) {
    long timeout = config.locking().lockAcquisitionTimeout();
    List<Duration> intervals = new LinkedList<>();
    // Generate exponential back-off intervals
    for (long interval = timeout; interval > 1; interval /= 10) {
      intervals.add(0, Duration.ofMillis(interval));
    }
    intervals.add(0, Duration.ZERO);
    return intervals;
  }
}

代码示例来源: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.wildfly/wildfly-clustering-ee-infinispan

private static List<Duration> calculateRetryIntervals(Configuration config) {
    long timeout = config.locking().lockAcquisitionTimeout();
    List<Duration> intervals = new LinkedList<>();
    // Generate exponential back-off intervals
    for (long interval = timeout; interval > 1; interval /= 10) {
      intervals.add(0, Duration.ofMillis(interval));
    }
    intervals.add(0, Duration.ZERO);
    return intervals;
  }
}

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

private static List<Duration> calculateRetryIntervals(Configuration config) {
    long timeout = config.locking().lockAcquisitionTimeout();
    List<Duration> intervals = new LinkedList<>();
    // Generate exponential back-off intervals
    for (long interval = timeout; interval > 1; interval /= 10) {
      intervals.add(0, Duration.ofMillis(interval));
    }
    intervals.add(0, Duration.ZERO);
    return intervals;
  }
}

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

@Override
  public void call() {
   Configuration cfg = cm.getCache().getCacheConfiguration();
   assertEquals(IsolationLevel.NONE, cfg.locking().isolationLevel());
  }
});

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

@Override
public void call() {
 Configuration cfg = cm.getDefaultCacheConfiguration();
 assertEquals(10000, cfg.locking().concurrencyLevel());
 assertEquals(IsolationLevel.REPEATABLE_READ, cfg.locking().isolationLevel());
}

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

@Override
  public void call() {
   Configuration cfg = cm.getCache().getCacheConfiguration();
   assertEquals(IsolationLevel.READ_COMMITTED,
      cfg.locking().isolationLevel());
  }
});

代码示例来源:origin: org.opendaylight.controller/clustering.services-implementation

@Override
public Properties getCacheProperties(String containerName, String cacheName) {
  EmbeddedCacheManager manager = this.cm;
  if (manager == null) {
    return null;
  }
  String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
  if (!manager.cacheExists(realCacheName)) {
    return null;
  }
  Configuration conf = manager.getCache(realCacheName).getAdvancedCache()
      .getCacheConfiguration();
  Properties p = new Properties();
  p.setProperty(IClusterServices.cacheProps.TRANSACTION_PROP.toString(),
      conf.transaction().toString());
  p.setProperty(IClusterServices.cacheProps.CLUSTERING_PROP.toString(),
      conf.clustering().toString());
  p.setProperty(IClusterServices.cacheProps.LOCKING_PROP.toString(), conf
      .locking().toString());
  return p;
}

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

/**
* Checks if the configuration (and the transaction manager) is able to handle client transactions.
*/
private void validateConfiguration(AdvancedCache<byte[], byte[]> cache) {
 Configuration configuration = cache.getCacheConfiguration();
 if (!configuration.transaction().transactionMode().isTransactional()) {
   throw log.expectedTransactionalCache(cache.getName());
 }
 if (configuration.locking().isolationLevel() != IsolationLevel.REPEATABLE_READ) {
   throw log.unexpectedIsolationLevel(cache.getName());
 }
 //TODO because of ISPN-7672, optimistic and total order transactions needs versions. however, versioning is currently broken
 if (configuration.transaction().lockingMode() == LockingMode.OPTIMISTIC ||
    configuration.transaction().transactionProtocol() == TransactionProtocol.TOTAL_ORDER) {
   //no Log. see comment above
   throw new IllegalStateException(
      String.format("Cache '%s' cannot use Optimistic neither Total Order transactions.", cache.getName()));
 }
}

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

public void testNullFoundButLoaderReceivedValueLaterInTransaction() throws SystemException, NotSupportedException {
 assertNotInCacheAndStore("k1");
 tm.begin();
 try {
   assertNull(cache.get("k1"));
   // Now simulate that someone else wrote to the store while during our tx
   store.write(new MarshalledEntryImpl("k1", "v1", null, sm));
   IsolationLevel level = cache.getCacheConfiguration().locking().isolationLevel();
   switch(level) {
    case READ_COMMITTED:
      assertEquals("v1", cache.get("k1"));
      break;
    case REPEATABLE_READ:
      assertNull(cache.get("k1"));
      break;
    default:
      fail("Unsupported isolation " + level + " - please change test to add desired outcome for isolation level");
   }
 } finally {
   tm.rollback();
 }
}

代码示例来源:origin: org.jboss.as/jboss-as-clustering-web-infinispan

public DistributedCacheManager(LocalDistributableSessionManager manager,
    Cache<String, Map<Object, Object>> cache, Registry<String, Void> registry,
    SharedLocalYieldingClusterLockManager lockManager, SessionAttributeStorage<T> attributeStorage,
    BatchingManager batchingManager, CacheInvoker invoker, KeyAffinityServiceFactory affinityFactory) {
  this.manager = manager;
  this.lockManager = lockManager;
  this.cache = cache;
  this.attributeStorage = attributeStorage;
  this.batchingManager = batchingManager;
  this.invoker = new ForceSynchronousCacheInvoker(invoker);
  this.lockTimeout = this.cache.getCacheConfiguration().locking().lockAcquisitionTimeout();
  Configuration configuration = this.cache.getCacheConfiguration();
  this.passivationEnabled = configuration.loaders().passivation() && !configuration.loaders().shared() && !configuration.loaders().cacheLoaders().isEmpty();
  this.persistenceEnabled = !configuration.loaders().passivation() && !configuration.loaders().cacheLoaders().isEmpty();
  this.registry = registry;
  this.affinity = affinityFactory.createService(cache, this);
}

代码示例来源: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

@Test(groups = "functional", expectedExceptions = { CacheException.class })
public void testLockAcquisitionTimeout() throws Exception {
 AdvancedCache<Object, Object> cache1 = advancedCache(0, "syncReplCache");
 AdvancedCache<Object, Object> cache2 = advancedCache(1, "syncReplCache");
 cache1.getCacheConfiguration().locking().lockAcquisitionTimeout(10);
 cache2.getCacheConfiguration().locking().lockAcquisitionTimeout(10);
 TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);
 // get a lock on cache 2 and hold on to it.
 EmbeddedTransactionManager tm = (EmbeddedTransactionManager) TestingUtil.getTransactionManager(cache2);
 tm.begin();
 cache2.put("block", "block");
 assertTrue(tm.getTransaction().runPrepare());
 tm.suspend();
 cache1.put("block", "v");
}

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

@Test
public void testIfSpringEmbeddedCacheManagerFactoryBeanAllowesOverridingConfigurationBuilder() throws Exception {
 ConfigurationBuilder overriddenBuilder = new ConfigurationBuilder();
 overriddenBuilder.locking().concurrencyLevel(100);
 objectUnderTest = SpringEmbeddedCacheManagerFactoryBeanBuilder
    .defaultBuilder().fromFile(NAMED_ASYNC_CACHE_CONFIG_LOCATION, getClass())
    .withConfigurationBuilder(overriddenBuilder).build();
 final SpringEmbeddedCacheManager springEmbeddedCacheManager = objectUnderTest.getObject();
 assertEquals(
    "Concurrency value of LockingLocking for cache configured in"
       + CACHE_NAME_FROM_CONFIGURATION_FILE + "is equal to 5000. But later Configuration Builder overrides "
       + "this setting to 100. Obviously created SpringEmbeddedCacheManagerFactoryBean does not support "
       + "this kind of overriding.",
    100,
    springEmbeddedCacheManager.getNativeCacheManager().getDefaultCacheConfiguration().locking()
       .concurrencyLevel());
}

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

@Test
public void testIfSpringEmbeddedCacheManagerFactoryBeanAllowesOverridingConfigurationBuilder() throws Exception {
 ConfigurationBuilder overriddenBuilder = new ConfigurationBuilder();
 overriddenBuilder.locking().concurrencyLevel(100);
 objectUnderTest = SpringEmbeddedCacheManagerFactoryBeanBuilder
    .defaultBuilder().fromFile(NAMED_ASYNC_CACHE_CONFIG_LOCATION, getClass())
    .withConfigurationBuilder(overriddenBuilder).build();
 final SpringEmbeddedCacheManager springEmbeddedCacheManager = objectUnderTest.getObject();
 assertEquals(
    "Concurrency value of LockingLocking for cache configured in"
       + CACHE_NAME_FROM_CONFIGURATION_FILE + "is equal to 5000. But later Configuration Builder overrides "
       + "this setting to 100. Obviously created SpringEmbeddedCacheManagerFactoryBean does not support "
       + "this kind of overriding.",
    100,
    springEmbeddedCacheManager.getNativeCacheManager().getDefaultCacheConfiguration().locking()
       .concurrencyLevel());
}

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

@Test
public void testIfSpringEmbeddedCacheManagerFactoryBeanAllowesOverridingConfigurationBuilder() throws Exception {
 ConfigurationBuilder overriddenBuilder = new ConfigurationBuilder();
 overriddenBuilder.locking().concurrencyLevel(100);
 objectUnderTest = SpringEmbeddedCacheManagerFactoryBeanBuilder
    .defaultBuilder().fromFile(NAMED_ASYNC_CACHE_CONFIG_LOCATION, getClass())
    .withConfigurationBuilder(overriddenBuilder).build();
 final SpringEmbeddedCacheManager springEmbeddedCacheManager = objectUnderTest.getObject();
 assertEquals(
    "Concurrency value of LockingLocking for cache configured in"
       + CACHE_NAME_FROM_CONFIGURATION_FILE + "is equal to 5000. But later Configuration Builder overrides "
       + "this setting to 100. Obviously created SpringEmbeddedCacheManagerFactoryBean does not support "
       + "this kind of overriding.",
    100,
    springEmbeddedCacheManager.getNativeCacheManager().getDefaultCacheConfiguration().locking()
       .concurrencyLevel());
}

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

public void testPartialOverride() {
 ConfigurationBuilder baseBuilder = new ConfigurationBuilder();
 baseBuilder.memory().size(200).storageType(StorageType.BINARY);
 Configuration base = baseBuilder.build();
 ConfigurationBuilder overrideBuilder = new ConfigurationBuilder();
 overrideBuilder.read(base).locking().concurrencyLevel(31);
 Configuration override = overrideBuilder.build();
 assertEquals(200, base.memory().size());
 assertEquals(200, override.memory().size());
 assertEquals(StorageType.BINARY, base.memory().storageType());
 assertEquals(StorageType.BINARY, override.memory().storageType());
 assertEquals(32, base.locking().concurrencyLevel());
 assertEquals(31, override.locking().concurrencyLevel());
}

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

public void testUserDefinedTimeouts() {
 HotRodServerConfigurationBuilder builder = new HotRodServerConfigurationBuilder();
 builder.topologyLockTimeout(26000).topologyReplTimeout(31000);
 withClusteredServer(builder, (cfg, distSyncTimeout) -> {
   assertEquals(cfg.locking().lockAcquisitionTimeout(), 26000);
   assertEquals(cfg.clustering().remoteTimeout(), 31000);
   assertTrue(cfg.clustering().stateTransfer().fetchInMemoryState());
   assertEquals(cfg.clustering().stateTransfer().timeout(), 31000 + distSyncTimeout);
   assertTrue(cfg.persistence().stores().isEmpty());
 });
}

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

public void testGlobalConfig() throws Exception {
   ConfigurationBuilderHolder holder = parse();
   GlobalConfiguration gc = holder.getGlobalConfigurationBuilder().build();
   BlockingThreadPoolExecutorFactory listenerThreadPool =
      gc.listenerThreadPool().threadPoolFactory();
   assertEquals(2, listenerThreadPool.maxThreads());

   BlockingThreadPoolExecutorFactory persistenceThreadPool =
      gc.persistenceThreadPool().threadPoolFactory();
   assertEquals(4, persistenceThreadPool.maxThreads());

   Properties transportProps = gc.transport().properties();
   assertEquals("jgroups-tcp.xml", transportProps.get("configurationFile"));

   Configuration configuration = holder.getDefaultConfigurationBuilder().build();
   assertEquals(IsolationLevel.READ_COMMITTED, configuration.locking().isolationLevel());
  }
}

相关文章