/** * Assigns the given Option to the cache's {@link InvocationContext}. Does * nothing if <code>option</code> is <code>null</code>. * * @param cache * the cache. Cannot be <code>null</code>. * @param option * the option. May be <code>null</code>. * * @see {@link Cache#getInvocationContext()} * @see {@link InvocationContext#setOptionOverrides(Option)} */ public static void setInvocationOption(Cache cache, Option option) { if (option != null) { cache.getInvocationContext().setOptionOverrides(option); } }
/** * Assigns the given Option to the cache's {@link InvocationContext}. Does * nothing if <code>option</code> is <code>null</code>. * * @param cache * the cache. Cannot be <code>null</code>. * @param option * the option. May be <code>null</code>. * * @see {@link Cache#getInvocationContext()} * @see {@link InvocationContext#setOptionOverrides(Option)} */ public static void setInvocationOption(Cache cache, Option option) { if (option != null) { cache.getInvocationContext().setOptionOverrides(option); } }
@Override public void afterCompletion(int status) { // could happen if a rollback is called and beforeCompletion() doesn't get called. if (ctx == null) ctx = invocationContextContainer.get(); ctx.setLocalRollbackOnly(localRollbackOnly); setTransactionalContext(tx, gtx, transactionContext, ctx); if (transactionalOptions != null) ctx.setOptionOverrides(transactionalOptions); try { super.afterCompletion(status); } finally { ctx.setOptionOverrides(originalOptions); } }
public void beforeCompletion() { if (trace) log.trace("Running beforeCompletion on gtx " + gtx); if (transactionContext == null) { log.error("Transaction has a null transaction entry - beforeCompletion() will fail."); throw new IllegalStateException("cannot find transaction entry for " + gtx); } modifications = transactionContext.getModifications(); ctx = invocationContextContainer.get(); setTransactionalContext(tx, gtx, transactionContext, ctx); if (ctx.isOptionsUninitialised() && transactionContext.getOption() != null) { ctx.setOptionOverrides(transactionContext.getOption()); } assertCanContinue(); ctx.setOriginLocal(false); }
public Node<K, V> addChild(Fqn f) { // TODO: Revisit. Is this really threadsafe? See comment in putIfAbsent() - same solution should be applied here too. assertValid(); Fqn nf = Fqn.fromRelativeFqn(getFqn(), f); Option o1 = spi.getInvocationContext().getOptionOverrides().copy(); Node<K, V> child = getChild(f); if (child == null) { if (trace) log.trace("Child is null; creating."); Option o2 = o1.copy(); spi.getInvocationContext().setOptionOverrides(o1); spi.put(nf, null); if (trace) log.trace("Created. Now getting again."); spi.getInvocationContext().setOptionOverrides(o2); child = getChild(f); if (trace) log.trace("Got child " + child); } return child; }
private Object handleDataVersionCommand(InvocationContext ctx, VersionedDataCommand command) throws Throwable { Option originalOption = ctx.getOptionOverrides(); if (command.isVersioned()) { Option option = new Option(); option.setDataVersion(command.getDataVersion()); ctx.setOptionOverrides(option); } Object retval; try { retval = invokeNextInterceptor(ctx, command); assertTxIsStillValid(ctx.getTransaction()); } catch (Throwable t) { log.error("method invocation failed", t); throw t; } finally { ctx.setOptionOverrides(originalOption); } return retval; } }
ctx.setOptionOverrides(transactionContext.getOption()); ctx.setOptionOverrides(transactionContext.getOption()); ctx.getOptionOverrides().setSuppressEventNotification(isSuppressEventNotification);
/** * Sets the state of the InvocationContext based on the template context passed in * * @param template template to copy from */ public void setState(InvocationContext template) { if (template == null) { throw new NullPointerException("Template InvocationContext passed in to InvocationContext.setState() passed in is null"); } this.setGlobalTransaction(template.getGlobalTransaction()); this.setLocalRollbackOnly(template.isLocalRollbackOnly()); this.setOptionOverrides(template.getOptionOverrides()); this.setOriginLocal(template.isOriginLocal()); this.setTransaction(template.getTransaction()); }
transactionalOptions = transactionContext.getOption(); transactionalOptions.setSuppressEventNotification(originalOptions.isSuppressEventNotification()); ctx.setOptionOverrides(transactionalOptions); ctx.setOptionOverrides(originalOptions);
public void destroy() throws CacheException { try { // NOTE : this is being used from the process of shutting down a // SessionFactory. Specific things to consider: // (1) this clearing of the region should not propagate to // other nodes on the cluster (if any); this is the // cache-mode-local option bit... // (2) really just trying a best effort to cleanup after // ourselves; lock failures, etc are not critical here; // this is the fail-silently option bit... Option option = new Option(); option.setCacheModeLocal(true); option.setFailSilently(true); if (optimistic) { option.setDataVersion(NonLockingDataVersion.INSTANCE); } jbcCache.getInvocationContext().setOptionOverrides(option); jbcCache.removeNode(regionFqn); deactivateLocalNode(); } catch (Exception e) { throw new CacheException(e); } // finally { // if (listener != null) // jbcCache.removeCacheListener(listener); // } }
public void destroy() throws CacheException { try { // NOTE : this is being used from the process of shutting down a // SessionFactory. Specific things to consider: // (1) this clearing of the region should not propagate to // other nodes on the cluster (if any); this is the // cache-mode-local option bit... // (2) really just trying a best effort to cleanup after // ourselves; lock failures, etc are not critical here; // this is the fail-silently option bit... Option option = new Option(); option.setCacheModeLocal(true); option.setFailSilently(true); if (optimistic) { option.setDataVersion(NonLockingDataVersion.INSTANCE); } jbcCache.getInvocationContext().setOptionOverrides(option); jbcCache.removeNode(regionFqn); deactivateLocalNode(); } catch (Exception e) { throw new CacheException(e); } finally { jbcCache.removeCacheListener(this); } }
public boolean removeNode(Fqn fqn) { // special case if we are removing the root. Remove all children instead. if (fqn.isRoot()) { boolean result = true; // we need to preserve options InvocationContext ctx = getInvocationContext(); Option o = ctx.getOptionOverrides().copy(); Set<Fqn> internalFqns = getInternalFqns(); for (Object childName : peek(fqn, false, false).getChildrenNames()) { if (!internalFqns.contains(Fqn.fromElements(childName))) { ctx.setOptionOverrides(o.copy()); result = removeNode(Fqn.fromRelativeElements(fqn, childName)) && result; } } return result; } else { InvocationContext ctx = invocationContextContainer.get(); cacheStatusCheck(ctx); GlobalTransaction tx = transactionTable.getCurrentTransaction(); RemoveNodeCommand command = commandsFactory.buildRemoveNodeCommand(tx, fqn); Object retval = invoker.invoke(ctx, command); return retval != null && (Boolean) retval; } }