public static AbstractActor<?> currentActor() { final ActorTaskContext current = current(); return current != null ? current.getActor() : null; } }
/** * Sets the runtime associated with the current thread. * <p> * It also tries to set the static runtime if the previous one got garbage collected. * </p> * <p> It's not necessary to "unset" the runtime because: * <ol> * <li>there should normally exist only one (only test cases are expected to have more than one)</li> * <li>it is already a weak reference</li> * <li>if another runtime is using the same thread later (shared thread pools) it will set the runtime before each usage</li> * </ol></p> * * @param runtimeRef a reference to the runtime */ public static void setRuntime(final WeakReference<? extends BasicRuntime> runtimeRef) { if (runtimeRef.get() instanceof ActorRuntime) { final ActorTaskContext context = ActorTaskContext.current(); if (context != null) { context.setRuntime((ActorRuntime) runtimeRef.get()); } } currentRuntime.set(runtimeRef); lastRuntime = runtimeRef; }
final ActorTaskContext context = ActorTaskContext.current(); if (context != null)
@Override public Task<?> invoke(final RemoteReference toReference, final Method m, final boolean oneWay, final int methodId, final Object[] params) { if (state == NodeCapabilities.NodeState.STOPPED) { throw new IllegalStateException("Stage is stopped. " + this.toString()); } final Invocation invocation = new Invocation(toReference, m, oneWay, methodId, params, null); // copy stick context valued to the message headers headers final ActorTaskContext context = ActorTaskContext.current(); if (context != null) { Map<String, Object> headers = null; for (final String key : stickyHeaders) { final Object value = context.getProperty(key); if (value != null) { if (headers == null) { headers = new HashMap<>(); } headers.put(key, value); } } invocation.setHeaders(headers); } final Task<Void> result = pipeline.write(invocation); return result; }
private String getFrom(final RemoteReference reference, final Method method) final ActorTaskContext context = ActorTaskContext.current(); String from; if (context != null && context.getActor() != null)
ActorTaskContext.current().setActor(actor); actor.reference = reference; actor.runtime = runtime;
final ActorTaskContext context = ActorTaskContext.current(); if (context != null)
public static AbstractActor<?> currentActor() { final ActorTaskContext current = current(); return current != null ? current.getActor() : null; } }
/** * Sets the runtime associated with the current thread. * <p> * It also tries to set the static runtime if the previous one got garbage collected. * </p> * <p> It's not necessary to "unset" the runtime because: * <ol> * <li>there should normally exist only one (only test cases are expected to have more than one)</li> * <li>it is already a weak reference</li> * <li>if another runtime is using the same thread later (shared thread pools) it will set the runtime before each usage</li> * </ol></p> * * @param runtimeRef a reference to the runtime */ public static void setRuntime(final WeakReference<? extends BasicRuntime> runtimeRef) { if (runtimeRef.get() instanceof ActorRuntime) { final ActorTaskContext context = ActorTaskContext.current(); if (context != null) { context.setRuntime((ActorRuntime) runtimeRef.get()); } } currentRuntime.set(runtimeRef); lastRuntime = runtimeRef; }
final ActorTaskContext context = ActorTaskContext.current(); if (context != null)