/** * Resolves key in the * {@link BasicExecutionContext#getCurrentExecutionContext current execution context}. * @see #resolve(ConfigBag, ConfigKey, ExecutionContext) */ public static <T> T resolve(ConfigBag configBag, ConfigKey<T> key) { return resolve(configBag, key, BasicExecutionContext.getCurrentExecutionContext()); }
protected void submitIfNecessary(TaskAdaptable<?> task) { if (!task.asTask().isSubmitted()) { if (BasicExecutionContext.getCurrentExecutionContext() == null) { throw new IllegalStateException("Compound task ("+task+") launched from "+this+" missing required execution context"); } else { BasicExecutionContext.getCurrentExecutionContext().submit(task); } } }
@Override protected <T> Task<T> runAtEntity(final Entity entity, final Effector<T> eff, @SuppressWarnings("rawtypes") final Map parameters) { manageIfNecessary(entity, eff); // prefer to submit this from the current execution context so it sets up correct cross-context chaining ExecutionContext ec = BasicExecutionContext.getCurrentExecutionContext(); if (ec == null) { log.debug("Top-level effector invocation: {} on {}", eff, entity); ec = getExecutionContext(entity); } return runAtEntity(entity, Effectors.invocation(entity, eff, parameters)); }
BasicExecutionContext ec = BasicExecutionContext.getCurrentExecutionContext(); if (log.isTraceEnabled()) { log.trace("task {} - submitting background task {} ({})", new Object[] { Tasks.current(), task, ec });
@Override public T call() throws Exception { if (!task.asTask().isSubmitted()) { BasicExecutionContext.getCurrentExecutionContext().submit(task); } return transformer.apply(task.asTask().get()); }}); }
private boolean orSubmitInternal() { if (!wasQueued()) { if (isQueuedOrSubmitted()) { log.warn("Redundant call to execute "+getTask()+"; skipping"); return false; } else { ExecutionContext ec = execContext; if (ec==null) ec = BasicExecutionContext.getCurrentExecutionContext(); if (ec==null) throw new IllegalStateException("Cannot execute "+getTask()+" without an execution context; ensure caller is in an ExecutionContext"); ec.submit(getTask()); return true; } } else { return false; } } /** causes the task to be submitted (asynchronously) if it hasn't already been,
@Override public void spawnchild() throws Exception { // spawn a child, then wait BasicExecutionContext.getCurrentExecutionContext().submit( MutableMap.of("displayName", "SpawnedChildName"), new Callable<Void>() { @Override public Void call() throws Exception { log.info("beginning spawned child response "+Tasks.current()+", with tags "+Tasks.current().getTags()); Tasks.setBlockingDetails("spawned child blocking details"); nowWaitingLatch.countDown(); if (!continueFromWaitingLatch.await(TIMEOUT, TimeUnit.MILLISECONDS)) { fail("took too long to be told to continue"); } return null; }}); }
BasicExecutionContext oldExecutionContext = getCurrentExecutionContext(); registerPerThreadExecutionContext();
BasicExecutionContext ec = BasicExecutionContext.getCurrentExecutionContext(); if (ec!=null) return ec.submit(taskScheduled); else return submit(taskScheduled);
if (exec==null) { exec = BasicExecutionContext.getCurrentExecutionContext();
throw new IllegalStateException("Must be either master or hot standby/backup to rebind (mode "+mode+")"); ExecutionContext ec = BasicExecutionContext.getCurrentExecutionContext(); if (ec == null) { ec = managementContext.getServerExecutionContext();