本文整理了Java中org.infinispan.Cache.endBatch()
方法的一些代码示例,展示了Cache.endBatch()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.endBatch()
方法的具体详情如下:
包路径:org.infinispan.Cache
类名称:Cache
方法名:endBatch
暂无
代码示例来源:origin: org.keycloak/keycloak-model-infinispan
public void endRevisionBatch() {
try {
revisions.endBatch(true);
} catch (Exception e) {
}
}
代码示例来源:origin: org.infinispan/infinispan-cli-server
@Override
public Result execute(Session session) {
Cache<Object, Object> cache = session.getCache(cacheName);
cache.endBatch(success);
return EmptyResult.RESULT;
}
代码示例来源:origin: org.infinispan/infinispan-cli-interpreter
@Override
public Result execute(Session session) {
Cache<Object, Object> cache = session.getCache(cacheName);
cache.endBatch(success);
return EmptyResult.RESULT;
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testEndBatchWithoutStartBatch(Method method) {
Cache<String, String> cache = createCache(method.getName());
cache.endBatch(true);
cache.endBatch(false);
// should not fail.
}
代码示例来源:origin: org.infinispan/infinispan-cli-server
private void resetCache(final Cache<Object, Object> cache) {
if (cache.getCacheConfiguration().invocationBatching().enabled()) {
cache.endBatch(false);
}
TransactionManager tm = cache.getAdvancedCache().getTransactionManager();
try {
if (tm.getTransaction() != null) {
tm.rollback();
}
} catch (Exception e) {
}
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testBatchWithoutCfg(Method method) {
Cache<String, String> cache = createCache(false, method.getName());
Exceptions.expectException(CacheConfigurationException.class, cache::startBatch);
Exceptions.expectException(CacheConfigurationException.class, () -> cache.endBatch(true));
Exceptions.expectException(CacheConfigurationException.class, () -> cache.endBatch(false));
}
代码示例来源:origin: org.infinispan/infinispan-core
String getOnDifferentThread(final Cache<String, String> cache, final String key) throws Exception {
Future<String> f = fork(() -> {
cache.startBatch();
String v = cache.get(key);
cache.endBatch(true);
return v;
});
return f.get();
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testActivationPutAllInBatchRolledBack() throws Exception {
Cache<String, String> testCache = cacheManager.getCache(CACHE_NAME);
final String key = "X";
final String value = "4567";
testCache.clear();
testCache.put(key, value);
testCache.evict(key);
// Now make sure the act of activation for the entry is not tied to the transaction
testCache.startBatch();
testCache.putAll(Collections.singletonMap(key, value + "-putall"));
testCache.endBatch(false);
// The data should still be present even if a rollback occurred
assertEquals(value, testCache.get(key));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testActivationInBatchRolledBack() {
Cache<String, String> testCache = cacheManager.getCache(CACHE_NAME);
final String key = "X";
final String value = "4567";
testCache.clear();
testCache.put(key, value);
testCache.evict(key);
// Now make sure the act of activation for the entry is not tied to the transaction
testCache.startBatch();
assertEquals(value, testCache.get(key));
testCache.endBatch(false);
// The data should still be present even if a rollback occurred
assertEquals(value, testCache.get(key));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testExpectedEnlistmentMode() {
TransactionManager tm = cache.getAdvancedCache().getTransactionManager();
assert tm instanceof BatchModeTransactionManager;
TransactionTable tt = TestingUtil.getTransactionTable(cache);
assertEquals(tt.getClass(), TransactionTable.class);
BatchContainer bc = TestingUtil.extractComponent(cache, BatchContainer.class);
cache.startBatch();
cache.put("k", "v");
assert getBatchTx(bc).getEnlistedSynchronization().size() == 1;
assert getBatchTx(bc).getEnlistedResources().size() == 0;
cache.endBatch(true);
assert getBatchTx(bc) == null;
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testLockWithBatchingRollback() {
cache.startBatch();
cache.getAdvancedCache().lock("k");
assertTrue(lockManager().isLocked("k"));
cache().endBatch(false);
assertFalse(lockManager().isLocked("k"));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testLockWithBatchingCommit() {
cache.startBatch();
cache.getAdvancedCache().lock("k");
assertTrue(lockManager().isLocked("k"));
cache().endBatch(true);
assertFalse(lockManager().isLocked("k"));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testBatchVisibility(Method method) throws Exception {
Cache<String, String> cache = createCache(method.getName());
cache.startBatch();
cache.put("k", "v");
assertNull("Other thread should not see batch update till batch completes!", getOnDifferentThread(cache, "k"));
cache.endBatch(true);
AssertJUnit.assertEquals("v", getOnDifferentThread(cache, "k"));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testBatchWithOngoingTM(Method method) throws Exception {
Cache<String, String> cache = createCache(method.getName());
TransactionManager tm = getTransactionManager(cache);
assertEquals(MyDummyTransactionManager.class, tm.getClass());
tm.begin();
cache.put("k", "v");
cache.startBatch();
cache.put("k2", "v2");
tm.commit();
assertEquals("v", cache.get("k"));
assertEquals("v2", cache.get("k2"));
cache.endBatch(false); // should be a no op
assertEquals("v", cache.get("k"));
assertEquals("v2", cache.get("k2"));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testStartBatchIdempotency(Method method) {
Cache<String, String> cache = createCache(method.getName());
cache.startBatch();
cache.put("k", "v");
cache.startBatch(); // again
cache.put("k2", "v2");
cache.endBatch(true);
AssertJUnit.assertEquals("v", cache.get("k"));
AssertJUnit.assertEquals("v2", cache.get("k2"));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testClearInBatch(Method method) {
//tests if the clear doesn't leak the batch transaction.
//if it does, the get() will be executed against a committed transaction and it will fail.
Cache<String, String> cache = createCache(method.getName());
cache.put("k2", "v2");
cache.startBatch();
cache.clear();
cache.put("k1", "v1");
cache.endBatch(true);
assertEquals(null, cache.get("k2"));
assertEquals("v1", cache.get("k1"));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testBatchRollback(Method method) throws Exception {
Cache<String, String> cache = createCache(method.getName());
cache.startBatch();
cache.put("k", "v");
cache.put("k2", "v2");
assertNull(getOnDifferentThread(cache, "k"));
assertNull(getOnDifferentThread(cache, "k2"));
cache.endBatch(false);
assertNull(getOnDifferentThread(cache, "k"));
assertNull(getOnDifferentThread(cache, "k2"));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testBatchRollback(Method method) throws Exception {
Cache<String, String> cache = createCache(method.getName());
cache.startBatch();
cache.put("k", "v");
cache.put("k2", "v2");
assertNull(getOnDifferentThread(cache, "k"));
assertNull(getOnDifferentThread(cache, "k2"));
cache.endBatch(false);
assertNull(getOnDifferentThread(cache, "k"));
assertNull(getOnDifferentThread(cache, "k2"));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testBatchRollback(Method method) throws Exception {
Cache<String, String> cache = createCache(method.getName());
cache.startBatch();
cache.put("k", "v");
cache.put("k2", "v2");
assertNull(getOnDifferentThread(cache, "k"));
assertNull(getOnDifferentThread(cache, "k2"));
cache.endBatch(false);
assertNull(getOnDifferentThread(cache, "k"));
assertNull(getOnDifferentThread(cache, "k2"));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testSkipLookupOnGetWhileBatching() {
MagicKey k1 = new MagicKey(c1, c2);
c1.put(k1, "batchingMagicValue-h1");
assertIsInContainerImmortal(c1, k1);
assertIsInContainerImmortal(c2, k1);
assertIsNotInL1(c3, k1);
assertIsNotInL1(c4, k1);
c4.startBatch();
assert c4.getAdvancedCache().withFlags(SKIP_REMOTE_LOOKUP).get(k1) == null;
c4.endBatch(true);
assertOwnershipAndNonOwnership(k1, false);
}
}
内容来源于网络,如有侵权,请联系作者删除!