本文整理了Java中org.infinispan.Cache.getAdvancedCache()
方法的一些代码示例,展示了Cache.getAdvancedCache()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.getAdvancedCache()
方法的具体详情如下:
包路径:org.infinispan.Cache
类名称:Cache
方法名:getAdvancedCache
暂无
代码示例来源:origin: wildfly/wildfly
@SuppressWarnings("unchecked")
public InfinispanSessionMetaDataFactory(Cache<? extends Key<String>, ?> cache, CacheProperties properties) {
this.creationMetaDataCache = (Cache<SessionCreationMetaDataKey, SessionCreationMetaDataEntry<L>>) cache;
this.findCreationMetaDataCache = properties.isLockOnRead() ? this.creationMetaDataCache.getAdvancedCache().withFlags(Flag.FORCE_WRITE_LOCK) : this.creationMetaDataCache;
this.accessMetaDataCache = (Cache<SessionAccessMetaDataKey, SessionAccessMetaData>) cache;
this.properties = properties;
}
代码示例来源:origin: wildfly/wildfly
private InfinispanSessionMetaData<L> getValue(String id, Cache<SessionCreationMetaDataKey, SessionCreationMetaDataEntry<L>> creationMetaDataCache) {
SessionCreationMetaDataKey key = new SessionCreationMetaDataKey(id);
SessionCreationMetaDataEntry<L> creationMetaDataEntry = creationMetaDataCache.get(key);
if (creationMetaDataEntry != null) {
SessionAccessMetaData accessMetaData = this.accessMetaDataCache.get(new SessionAccessMetaDataKey(id));
if (accessMetaData != null) {
return new InfinispanSessionMetaData<>(creationMetaDataEntry.getMetaData(), accessMetaData, creationMetaDataEntry.getLocalContext());
}
// Purge orphaned entry, making sure not to trigger cache listener
creationMetaDataCache.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES, Flag.SKIP_LISTENER_NOTIFICATION).remove(key);
}
return null;
}
代码示例来源:origin: org.infinispan/infinispan-core
@Override
public void call() {
cache.put("k1", "v1");
cache.put("k2", "v2");
assertEquals("cache size must be 1", 1, cache.getAdvancedCache().getDataContainer().size());
}
});
代码示例来源:origin: org.infinispan/infinispan-core
public void testFailure() throws Exception {
TransactionManager transactionManager = cache.getAdvancedCache().getTransactionManager();
transactionManager.begin();
try {
cache.put("k", "v");
assert false;
} catch (Exception e) {
log.debug("Ignoring expected exception during put", e);
assertEquals(transactionManager.getTransaction().getStatus(), Status.STATUS_MARKED_ROLLBACK);
}
}
}
代码示例来源:origin: org.infinispan/infinispan-core
@Override
protected <K> void assertL1StateOnLocalWrite(Cache<? super K, ?> cache, Cache<?, ?> updatingCache, K key, Object valueWrite) {
if (cache != updatingCache) {
super.assertL1StateOnLocalWrite(cache, updatingCache, key, valueWrite);
}
else {
InternalCacheEntry ice = cache.getAdvancedCache().getDataContainer().get(key);
assertNotNull(ice);
assertEquals(valueWrite, ice.getValue());
}
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testShort() throws Exception {
long numberInserted = CACHE_SIZE / 2;
Random random = new Random();
// Note that there is overhead for the map itself, so we will not get exactly the same amount
// More than likely there will be a few hundred byte overhead
for (short i = 0; i < numberInserted; i++) {
cache.put(i, Short.valueOf((short) random.nextInt(Short.MAX_VALUE + 1)));
}
assertTrue(cache.getAdvancedCache().getDataContainer().size() < numberInserted);
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testReplaceFromNonOwnerWithFlag() throws Exception {
String key = "k1", value = "value", value2 = "v2";
initAndTest();
Object retval = getFirstNonOwner(key).getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).replace(key, value2);
if (testRetVals) assert value.equals(retval);
assertEquals(getFirstOwner(key).get(key), value2);
assertInStores(key, value, true);
}
代码示例来源:origin: org.infinispan/infinispan-core
@Override
public void call() {
Cache<byte[], byte[]> cache = cm.getCache();
byte[] key = "key1".getBytes(ISO_8859_1);
byte[] value = new byte[]{97, 118, 105, -61, -93, 111}; // 'avião' in UTF-8
cache.put(key, value);
assertEquals(cache.get(key), value);
// Value as UTF-16
Cache<byte[], byte[]> utf16ValueCache = (Cache<byte[], byte[]>) cache.getAdvancedCache().withMediaType("text/plain; charset=ISO-8859-1", "text/plain; charset=UTF-16");
assertEquals(utf16ValueCache.get(key), new byte[]{-2, -1, 0, 97, 0, 118, 0, 105, 0, -29, 0, 111});
}
});
代码示例来源:origin: org.infinispan/infinispan-core
public void testDelayed(Method m) {
initAndCheck(m);
CountDownLatch release = new CountDownLatch(1);
cache(1).getAdvancedCache().getAsyncInterceptorChain().addInterceptor(new DelayingInterceptor(null, release), 0);
long requestStart = System.nanoTime();
assertEquals(m.getName(), cache(0).get(key));
long requestEnd = System.nanoTime();
long remoteTimeout = cache(0).getCacheConfiguration().clustering().remoteTimeout();
long delay = TimeUnit.NANOSECONDS.toMillis(requestEnd - requestStart);
assertTrue(delay < remoteTimeout);
release.countDown();
}
代码示例来源:origin: org.infinispan/infinispan-core
protected void verifyInitialData(Cache<Object, Object> c) {
Address address = c.getAdvancedCache().getRpcManager().getAddress();
log.debugf("Checking values on cache " + address);
assertEquals("Incorrect value for key " + A_B_NAME, JOE, c.get(A_B_NAME));
assertEquals("Incorrect value for key " + A_B_AGE, TWENTY, c.get(A_B_AGE));
assertEquals("Incorrect value for key " + A_C_NAME, BOB, c.get(A_C_NAME));
assertEquals("Incorrect value for key " + A_C_AGE, FORTY, c.get(A_C_AGE));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testCorrectFunctionalityOnUnconditionalWrite() {
MagicKey k1 = getMagicKey();
c1.put(k1, "value");
assertIsInContainerImmortal(c1, k1);
assertIsInContainerImmortal(c2, k1);
assertIsNotInL1(c3, k1);
assertIsNotInL1(c4, k1);
assertNull(c4.getAdvancedCache().withFlags(SKIP_REMOTE_LOOKUP).put(k1, "new_val"));
assertEquals(c3.get(k1), "new_val");
assertOnAllCachesAndOwnership(k1, "new_val");
}
代码示例来源:origin: org.infinispan/infinispan-core
protected void assertKeyNotAvailableForRead(Cache<Object, ?> c, Object key) {
log.tracef("Checking key %s is not available on %s", key, c);
expectException(AvailabilityException.class, () -> c.get(key));
expectException(AvailabilityException.class, () -> c.getAdvancedCache().getAll(Collections.singleton(key)));
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testSizeWithEvictedEntriesAndFlags() {
final int numKeys = 300;
for (int i = 0; i < numKeys; i++) {
cache.put(i, i);
}
assertFalse("Data Container should not have all keys", numKeys == cache.getAdvancedCache().getDataContainer().size());
assertEquals(cache.getAdvancedCache().getDataContainer().size(), cache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_LOAD).size());
// Skip cache store only prevents writes not reads
assertEquals(300, cache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).size());
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testMultiLockSuccess() throws Exception {
Cache<String, String> cache1 = cache(0);
cache1.put("k1", "v");
cache1.put("k2", "v");
cache1.put("k3", "v");
tm(0).begin();
assert cache1.getAdvancedCache().lock(Arrays.asList("k1", "k2", "k3"));
tm(0).rollback();
}
代码示例来源:origin: wildfly/wildfly
public InfinispanSSOFactory(Cache<AuthenticationKey, AuthenticationEntry<AV, L>> cache, CacheProperties properties, Marshaller<A, AV> marshaller, LocalContextFactory<L> localContextFactory, SessionsFactory<SV, D, S> sessionsFactory) {
this.cache = cache;
this.findCache = properties.isLockOnRead() ? cache.getAdvancedCache().withFlags(Flag.FORCE_WRITE_LOCK) : cache;
this.marshaller = marshaller;
this.localContextFactory = localContextFactory;
this.sessionsFactory = sessionsFactory;
}
代码示例来源:origin: org.infinispan/infinispan-core
protected void assertNumberOfEntries(int cacheIndex, DeltaAwareAccessor daa) throws Exception {
AdvancedCacheLoader loader = (AdvancedCacheLoader) TestingUtil.getCacheLoader(cache(cacheIndex));
assertEquals(daa.isFineGrained() ? 6 : 2, PersistenceUtil.count(loader, null)); // two entries in store
DataContainer dataContainer = cache(cacheIndex).getAdvancedCache().getDataContainer();
assertEquals(1, dataContainer.size()); // only one entry in memory (the other one was evicted)
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testInteger() throws Exception {
long numberInserted = CACHE_SIZE / 8;
Random random = new Random();
// Note that there is overhead for the map itself, so we will not get exactly the same amount
// More than likely there will be a few hundred byte overhead
for (int i = 0; i < numberInserted; i++) {
cache.put(i, Integer.valueOf(random.nextInt()));
}
assertTrue(cache.getAdvancedCache().getDataContainer().size() < numberInserted);
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testAtomicPutIfAbsentFromNonOwnerWithFlag(Method m) throws Exception {
String key = k(m), value = "value";
String replaced = getFirstNonOwner(key).getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).putIfAbsent(key, value);
assertNull(replaced);
//interesting case: fails to put as value exists, put actually missing in Store
replaced = getFirstNonOwner(key).putIfAbsent(key, value);
assertEquals(replaced, value);
for (Cache<Object, String> c : caches) {
assertEquals(replaced, c.get(key));
CacheLoader store = TestingUtil.getFirstLoader(c);
assertFalse(store.contains(key));
}
}
代码示例来源:origin: org.infinispan/infinispan-core
public void assertKeyAvailableForWrite(Object k, Object newValue) {
for (Cache<Object, Object> c : cachesInThisPartition()) {
c.put(k, newValue);
assertEquals(c.get(k), newValue, "Cache " + c.getAdvancedCache().getRpcManager().getAddress() + " doesn't see the right value");
}
}
代码示例来源:origin: org.infinispan/infinispan-core
public void testSizeWithEvictedEntries() {
final int numKeys = 300;
for (int i = 0; i < numKeys; i++) {
cache.put(i, i);
}
assertFalse("Data Container should not have all keys", numKeys == cache.getAdvancedCache().getDataContainer().size());
assertEquals(numKeys, cache.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL).size());
}
内容来源于网络,如有侵权,请联系作者删除!