@Override public boolean remove(String id) { return this.cache.getAdvancedCache().remove(new CoarseSessionsKey(id)) != null; } }
@Override public boolean remove(String id) { Map<String, UUID> names = this.namesCache.getAdvancedCache().withFlags(Flag.FORCE_SYNCHRONOUS).remove(new SessionAttributeNamesKey(id)); if (names != null) { for (UUID attributeId : names.values()) { this.attributeCache.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES).remove(new SessionAttributeKey(id, attributeId)); } } return true; }
@Override public boolean remove(String id) { this.cache.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES).remove(new SessionAttributesKey(id)); return true; }
@Override public boolean remove(I id) { this.cache.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES).remove(this.createKey(id)); return true; }
@Override public boolean remove(String id) { this.cache.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES).remove(new AuthenticationKey(id)); this.sessionsFactory.remove(id); return true; }
private boolean remove(String id, Cache<SessionCreationMetaDataKey, SessionCreationMetaDataEntry<L>> creationMetaDataCache) { SessionCreationMetaDataKey key = new SessionCreationMetaDataKey(id); try { if (!this.properties.isLockOnWrite() || (creationMetaDataCache.getAdvancedCache().getTransactionManager().getTransaction() == null) || creationMetaDataCache.getAdvancedCache().withFlags(Flag.ZERO_LOCK_ACQUISITION_TIMEOUT, Flag.FAIL_SILENTLY).lock(key)) { creationMetaDataCache.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES).remove(key); this.accessMetaDataCache.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES).remove(new SessionAccessMetaDataKey(id)); return true; } return false; } catch (SystemException e) { throw new CacheException(e); } }
@Override public void close() { this.cache.removeListener(this); this.shutdown(this.topologyChangeExecutor); try (Batch batch = this.batcher.createBatch()) { // If this remove fails, the entry will be auto-removed on topology change by the new primary owner this.cache.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES, Flag.FAIL_SILENTLY).remove(this.group.getAddress(this.group.getLocalMember())); } catch (CacheException e) { ClusteringLogger.ROOT_LOGGER.warn(e.getLocalizedMessage(), e); } finally { // Cleanup any unregistered listeners for (ExecutorService executor : this.listeners.values()) { this.shutdown(executor); } this.listeners.clear(); this.closeTask.run(); } }
@Override public Object removeAttribute(String name) { UUID attributeId = this.names.get(name); if (attributeId == null) return null; this.setNames(this.namesCache.getAdvancedCache().withFlags(Flag.FORCE_SYNCHRONOUS).computeIfPresent(this.createKey(), this.properties.isTransactional() ? new CopyOnWriteMapRemoveFunction<>(name) : new ConcurrentMapRemoveFunction<>(name))); Object result = this.read(name, this.attributeCache.getAdvancedCache().withFlags(Flag.FORCE_SYNCHRONOUS).remove(this.createKey(attributeId))); this.mutations.remove(name); return result; }
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; }
@Override public void remove(I id, RemoveListener<T> listener) { BeanEntry<I> entry = this.cache.getAdvancedCache().withFlags(Flag.FORCE_SYNCHRONOUS).remove(this.createKey(id)); if (entry != null) { I groupId = entry.getGroupId(); BeanGroupEntry<I, T> groupEntry = this.groupFactory.findValue(groupId); if (groupEntry != null) { try (BeanGroup<I, T> group = this.groupFactory.createGroup(groupId, groupEntry)) { T bean = group.removeBean(id); if (listener != null) { listener.removed(bean); } } } } } }
@Override public Bean<I, T> createBean(I id, BeanEntry<I> entry) { I groupId = entry.getGroupId(); BeanGroupEntry<I, T> groupEntry = this.groupFactory.findValue(groupId); if (groupEntry == null) { InfinispanEjbLogger.ROOT_LOGGER.invalidBeanGroup(id, groupId); this.cache.getAdvancedCache().withFlags(Flag.IGNORE_RETURN_VALUES).remove(this.createKey(id)); return null; } BeanGroup<I, T> group = this.groupFactory.createGroup(groupId, groupEntry); Mutator mutator = (entry.getLastAccessedTime() == null) ? Mutator.PASSIVE : new CacheEntryMutator<>(this.cache, this.createKey(id), entry); return new InfinispanBean<>(id, entry, group, mutator, this, this.timeout, this.listener); }
@Override public void apply() { setCacheLocalMode(Flag.SKIP_REMOTE_LOOKUP).remove(key, value); }
@Override public void apply() { setCacheLocalMode(Flag.SKIP_REMOTE_LOOKUP, Flag.IGNORE_RETURN_VALUES).remove(key); }
/** * {@inheritDoc} */ public void removeNodeQuota(String repositoryName, String workspaceName, String nodePath) { String workspaceUniqueName = composeWorkspaceUniqueName(repositoryName, workspaceName); CacheKey key = new NodeQuotaKey(workspaceUniqueName, nodePath); cache.remove(key); }
@Override protected void duringSplit(AdvancedCache preferredPartitionCache, AdvancedCache otherCache) { preferredPartitionCache.remove(conflictKey); otherCache.put(conflictKey, "DURING SPLIT"); } }
public void testFiringEntryRemovedEventWhenRemovingDataFromCache() throws Exception { //given cache1.put("pete", "Edinburgh"); //when cache1.remove("pete"); //then assertThat(cacheObserver, Cache1.class).hasEntryRemovedEvent("pete"); }
public void testConditionalRemove() { Object k = init(); assertTrue(advancedCache(0).withFlags(Flag.IGNORE_RETURN_VALUES).remove(k, "v0")); assertNull(cache(0).get(k)); assertNull(cache(1).get(k)); }
public void testRemoveFromNonOwnerWithFlags() throws Exception { String key = "k1", value = "value"; initAndTest(); Object retval = getFirstNonOwner(key).getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).remove(key); if (testRetVals) assert value.equals(retval); for (Cache<Object, String> c : caches) { if (isOwner(c, key)) { CacheLoader store = TestingUtil.getFirstLoader(c); assertTrue(store.contains(key)); } } }
private void introduceCacheConflicts() { LocalizedCacheTopology topology = getCache(0).getDistributionManager().getCacheTopology(); for (int i = 0; i < NUMBER_OF_CACHE_ENTRIES; i += INCONSISTENT_VALUE_INCREMENT) { Address primary = topology.getDistribution(i).primary(); AdvancedCache<Object, Object> primaryCache = manager(primary).getCache(CACHE_NAME).getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL); if (i % NULL_VALUE_FREQUENCY == 0) primaryCache.remove(i); else primaryCache.put(i, "INCONSISTENT"); } }
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")); }