@Override public BeanGroupEntry<I, T> tryValue(I id) { return this.findCache.getAdvancedCache().withFlags(Flag.ZERO_LOCK_ACQUISITION_TIMEOUT, Flag.FAIL_SILENTLY).get(this.createKey(id)); }
protected void assertCacheGet(Object key, Object value, int... caches) { for (int index : caches) { AdvancedCache cache = advancedCache(index); String message = String.format("Key=%s, Value=%s, Cache Index=%s, Topology=%s", key, value, index, cache.getDistributionManager().getCacheTopology()); assertEquals(message, value, cache.get(key)); } }
@Override public BeanEntry<I> tryValue(I id) { return this.findCache.getAdvancedCache().withFlags(Flag.ZERO_LOCK_ACQUISITION_TIMEOUT, Flag.FAIL_SILENTLY).get(this.createKey(id)); }
@CacheEntryPassivated public void passivated(CacheEntryPassivatedEvent<BeanGroupKey<I>, BeanGroupEntry<I, T>> event) { if (event.isPre()) { BeanGroupEntry<I, T> entry = event.getValue(); try (BeanGroup<I, T> group = new InfinispanBeanGroup<>(event.getKey().getId(), entry, this.context, Mutator.PASSIVE, this)) { for (I beanId : group.getBeans()) { BeanKey<I> beanKey = new InfinispanBeanKey<>(beanId); BeanEntry<I> beanEntry = this.beanCache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_LOAD).get(beanKey); if ((beanEntry != null) && this.beanFilter.test(new AbstractMap.SimpleImmutableEntry<>(beanKey, beanEntry))) { InfinispanEjbLogger.ROOT_LOGGER.tracef("Passivating bean %s", beanKey); this.passiveCount.incrementAndGet(); group.prePassivate(beanId, this.passivationListener); // Cascade evict to bean entry this.beanCache.evict(beanKey); } } } catch (Exception e) { InfinispanEjbLogger.ROOT_LOGGER.warn(e.getLocalizedMessage(), e); } } }
protected E fetchValue(int scoreIndex, NodeTopDocs nodeTopDocs) { Object[] keys = nodeTopDocs.keys; if (keys != null && keys.length > 0) { return (E) cache.get(keys[scoreIndex]); } return (E) nodeTopDocs.projections[scoreIndex]; }
public Long run() { return (Long)cache.withFlags(Flag.FORCE_WRITE_LOCK).get(key); } });
/** * @param fileName * @return the FileMetadata associated with the fileName, or null if the file wasn't found. */ public FileMetadata getFileMetadata(final String fileName) { FileCacheKey key = new FileCacheKey(indexName, fileName, affinitySegmentId); FileMetadata metadata = (FileMetadata) cache.get(key); return metadata; }
@Override public Object get(SessionImplementor session, Object key) throws CacheException { if (checkValid()) { return cache.get(key); } return null; }
@Override public Object get(Object session, Object key, long txTimestamp) throws CacheException { if (txTimestamp < region.getLastRegionInvalidation() ) { return null; } Object value = cache.get(key); if (value instanceof VersionedEntry) { return ((VersionedEntry) value).getValue(); } return value; }
private Object assertTestCorrectness() { AdvancedCache someCache = caches.get(0).getAdvancedCache(); final Object currentStored = someCache.get(SHARED_KEY); HashSet uniqueValueVerify = new HashSet(); for (SharedThreadState threadState : state.threadStates) { uniqueValueVerify.add(threadState.afterTargetValue); } if (uniqueValueVerify.size() != threads) { fail("test bug"); } return currentStored; }
public void testLocalOnlyClear() { AdvancedCache<String, String> cache1 = advancedCache(0,"invalidation"); AdvancedCache<String, String> cache2 = advancedCache(1,"invalidation"); cache1.withFlags(CACHE_MODE_LOCAL).put("key", "value1"); cache2.withFlags(CACHE_MODE_LOCAL).put("key", "value2"); assert cache1.get("key").equals("value1"); assert cache2.get("key").equals("value2"); cache1.withFlags(CACHE_MODE_LOCAL).clear(); assert cache1.get("key") == null; assert cache2.get("key") != null; assert cache2.get("key").equals("value2"); }
@Override QueryResponse perform() { DocumentExtractor extractor = getQueryBox().get(queryId); Object key = extractKey(extractor, docIndex); Object value = cache.get(key); return new QueryResponse(value); } }
public void testClear() { AdvancedCache<String, String> cache1 = advancedCache(0,"replication"); AdvancedCache<String, String> cache2 = advancedCache(1,"replication"); cache1.withFlags(CACHE_MODE_LOCAL).put("key", "value1"); cache2.withFlags(CACHE_MODE_LOCAL).put("key", "value2"); assert cache1.get("key").equals("value1"); assert cache2.get("key").equals("value2"); cache1.clear(); assert cache1.get("key") == null; assert cache2.get("key") == null; }
@Override public String call() throws Exception { TransactionManager mgr = TestingUtil.getTransactionManager(nonOwner); mgr.begin(); try { return nonOwner.getAdvancedCache().withFlags(Flag.FORCE_WRITE_LOCK).get(key); } finally { mgr.commit(); } } });
public void testPutOnNonOwner() { //todo [anistor] this does not test putAll ! MagicKey mk = new MagicKey("key", cache(0)); cache(3).getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP).put(mk, "value"); assert cache(0).getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP).get(mk) != null; assert cache(1).getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP).get(mk) == null; assert cache(2).getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP).get(mk) == null; assert cache(3).getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP).get(mk) == null; }
public void testFlagMissNotCounted() throws Exception { assertStoreAccess(0, 0, 0); cache.put("key", "value"); assertStoreAccess(0, 1, 1); cache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_LOAD).get("no_such_key"); assertStoreAccess(0, 1, 1); }
public void testSkipLookupOnGet() { 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).get(k1)); assertOwnershipAndNonOwnership(k1, false); }
public void testRemove() throws Exception { AdvancedCache<String, String> cache1 = advancedCache(0,"invalidation"); AdvancedCache<String, String> cache2 = advancedCache(1,"invalidation"); cache1.withFlags(CACHE_MODE_LOCAL).put("key", "value"); assertEquals("value", cache1.get("key")); cache2.withFlags(CACHE_MODE_LOCAL).put("key", "value"); assertEquals("value", cache2.get("key")); replListener(cache2).expectAny(); assertEquals("value", cache1.remove("key")); replListener(cache2).waitForRpc(); assertEquals(false, cache2.containsKey("key")); }
public void testROWhenHasOnlyLocksAndReleasedProperly() throws Exception { cache.put("k", "v"); tm().begin(); cache.getAdvancedCache().withFlags(Flag.FORCE_WRITE_LOCK).get("k"); assert TestingUtil.extractLockManager(cache).isLocked("k"); Transaction transaction = tm().suspend(); LocalXaTransaction localTransaction = (LocalXaTransaction) txTable().getLocalTransaction(transaction); assert localTransaction != null && localTransaction.isReadOnly(); tm().resume(transaction); tm().commit(); assert !TestingUtil.extractLockManager(cache).isLocked("k"); }