if (cache != null) cache.addCacheListener(cacheNotificationListener); cache.removeCacheListener(cacheNotificationListener);
/** * Evict the node under given Fqn from cache. * * @param fqn The fqn of a node in cache. * @throws Exception */ public void evict(Fqn fqn) throws Exception { cache_.evict(fqn, false); }
Node node = c.getRoot().getChild(fqn); Set<Object> children = node == null ? Collections.emptySet() : new HashSet(node.getChildrenNames()); output.writeObject(children); fqn = (Fqn) input.readObject(); key = input.readObject(); retval = c.get(fqn, key); output.writeObject(retval); break; case TcpCacheOperations.GET: fqn = (Fqn) input.readObject(); n = c.getNode(fqn); if (n == null) case TcpCacheOperations.EXISTS: fqn = (Fqn) input.readObject(); flag = c.getRoot().hasChild(fqn); output.writeObject(flag); break; key = input.readObject(); val = input.readObject(); retval = c.put(fqn, key, val); output.writeObject(retval); break; fqn = (Fqn) input.readObject(); map = (Map) input.readObject(); c.put(fqn, map);
InvocationContext ctx = cache.getInvocationContext(); ctx.getOptionOverrides().setLockAcquisitionTimeout((int) (cache.getConfiguration().getLockAcquisitionTimeout() + 5000)); BuddyManager buddyManager = cache.getBuddyManager(); ArrayList<Fqn> list = new ArrayList<Fqn>(); list.add(fqn); Set buddies = cache.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, false, false).getChildrenNames(); if (buddies != null) subtreeRoot = cache.peek(subtree, false); cache.evict(subtree, true);
Node subtreeRoot = cache.getNode(fqn); // NOTE this used to be a peek! BuddyManager buddyManager = cache.getBuddyManager(); Node root = cache.getRoot(); cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true); subtreeRoot = root.addChild(fqn); cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(false); List<Address> members = cache.getMembers(); if (!cache.getMembers().contains(buddy)) subtreeRoot = cache.peek(buddyRoot, false, false); if (subtreeRoot == null) NodeSPI root = cache.getRoot(); cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true); subtreeRoot = root.addChild(buddyRoot); cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(false);
dataContainer.registerInternalFqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN); buddyGroup = new BuddyGroup(); buddyGroup.setDataOwner(cache.getLocalAddress()); Address localAddress = rpcManager.getLocalAddress(); if (localAddress == null) cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true); if (!cache.exists(BUDDY_BACKUP_SUBTREE_FQN)) cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true); cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true); cache.put(BUDDY_BACKUP_SUBTREE_FQN, (Map) Collections.emptyMap()); cache.addCacheListener(viewChangeListener); reassignBuddies(cache.getMembers()); queue.clear(); asyncViewChangeHandler.start();
public void getState(ObjectOutputStream out, Fqn fqn, long timeout, boolean force, boolean suppressErrors) throws Exception boolean canProvideState = cache.getCacheStatus().allowInvocations() && !regionManager.isInactive(fqn) && cache.peek(fqn, false) != null; if (trace) log.trace("Can provide state? " + canProvideState); if (canProvideState && (fetchPersistentState || fetchTransientState)) InternalNode subtreeRoot = fqn.isRoot() ? cache.getRoot().getDelegationTarget() : cache.getNode(fqn).getDelegationTarget(); if (!canProvideState) String exceptionMessage = "Cache instance at " + cache.getLocalAddress() + " cannot provide state for fqn " + fqn + "."; if (!cache.getCacheStatus().allowInvocations()) exceptionMessage = " [Cache is not in the correct status]"; if (cache.peek(fqn, false, false) == null) e = new CacheException("Cache instance at " + cache.getLocalAddress() + " is not configured to provide state");
if (usePut) cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true); cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true); cache.clearData(fqn); cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true); cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true); cache.put(fqn, attrs); target = cache.getNode(fqn); parent.addChild(fqn.getLastElement(), target); Region region = cache.getRegion(fqn, false); if (region != null && region.getEvictionRegionConfig() != null)
try cache.getMarshaller().objectToObjectStream(STATE_TRANSFER_VERSION, out); if (generateTransient) CacheLoader cacheLoader = cache.getCacheLoaderManager() == null ? null : cache.getCacheLoaderManager().getCacheLoader(); if (cacheLoader != null && generatePersistent) log.trace("writing persistent state for " + fqn + ",using " + cache.getCacheLoaderManager().getCacheLoader().getClass()); cache.getMarshaller().objectToObjectStream(new NodeDataExceptionMarker(e, cache.getLocalAddress()), out); throw e;
private BackupData localBackupGet(Fqn fqn, InvocationContext ctx) throws CacheException { GravitateResult result = cacheSPI.gravitateData(fqn, true, ctx);// a "local" gravitation boolean found = result.isDataFound(); BackupData data = null; if (found) { Fqn backupFqn = result.getBuddyBackupFqn(); data = new BackupData(fqn, result); // now the cleanup if (buddyManager.isDataGravitationRemoveOnFind()) { // Remove locally only; the remote call will // be broadcast later ctx.getOptionOverrides().setCacheModeLocal(true); cacheSPI.removeNode(backupFqn); } else { cacheSPI.evict(backupFqn, true); } } if (trace) log.trace("Retrieved data " + data + " found = " + found); return data; }
sendStateChangeNotification(oldState, stoppingState, getClass().getSimpleName() + " stopping", null); cache.stop(); if (cache.getCacheStatus() == CacheStatus.DESTROYED)
cache.getInvocationContext().getOptionOverrides().setSkipDataGravitation(true); cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true); cache.get(fqn, "bla"); cache.get(tmp_fqn, "bla");
private boolean configuredToFetchState() { return configuration.isFetchInMemoryState() || (cache.getCacheLoaderManager() != null && cache.getCacheLoaderManager().isFetchPersistentState()); }
/** * A test to check whether the cache is in its started state. If not, calls should not be made as the channel may * not have properly started, blocks due to state transfers may be in progress, etc. * * @return true if the cache is in its STARTED state. */ protected boolean isCacheReady() { return cache.getCacheStatus() == CacheStatus.STARTED; }
public V get(K key) { assertValid(); return spi.get(getFqn(), key); }
@Override public void create() throws Exception { super.create(); cache.addCacheListener(new SingletonStoreListener()); }
public void clearData() { assertValid(); spi.clearData(getFqn()); }