public HystrixContextRunnable(final HystrixConcurrencyStrategy concurrencyStrategy, final HystrixRequestContext hystrixRequestContext, final Runnable actual) { this.actual = concurrencyStrategy.wrapCallable(new Callable<Void>() { @Override public Void call() throws Exception { actual.run(); return null; } }); this.parentThreadState = hystrixRequestContext; }
public HystrixContextCallable(HystrixConcurrencyStrategy concurrencyStrategy, Callable<K> actual) { this.actual = concurrencyStrategy.wrapCallable(actual); this.parentThreadState = HystrixRequestContext.getContextForCurrentThread(); }
public HystrixContexSchedulerAction(final HystrixConcurrencyStrategy concurrencyStrategy, Action0 action) { this.actual = action; this.parentThreadState = HystrixRequestContext.getContextForCurrentThread(); this.c = concurrencyStrategy.wrapCallable(new Callable<Void>() { @Override public Void call() throws Exception { HystrixRequestContext existingState = HystrixRequestContext.getContextForCurrentThread(); try { // set the state of this thread to that of its parent HystrixRequestContext.setContextOnCurrentThread(parentThreadState); // execute actual Action0 with the state of the parent actual.call(); return null; } finally { // restore this thread back to its original state HystrixRequestContext.setContextOnCurrentThread(existingState); } } }); }
@Override public <K> Callable<K> wrapCallable(Callable<K> c) { if (c instanceof FescarContextCallable) { return c; } Callable<K> wrappedCallable; if (this.delegate != null) { wrappedCallable = this.delegate.wrapCallable(c); } else { wrappedCallable = c; } if (wrappedCallable instanceof FescarContextCallable) { return wrappedCallable; } return new FescarContextCallable<>(wrappedCallable); }
@Override public <T> Callable<T> wrapCallable(Callable<T> callable) { if (callable instanceof TraceCallable) { return callable; } Callable<T> wrappedCallable = this.delegate != null ? this.delegate.wrapCallable(callable) : callable; if (wrappedCallable instanceof TraceCallable) { return wrappedCallable; } return new TraceCallable<>(this.tracing, this.spanNamer, wrappedCallable, HYSTRIX_COMPONENT); }
@Override public <T> Callable<T> wrapCallable(final Callable<T> callable) { return underlying().map(strategy -> strategy.wrapCallable(callable)) .orElseGet(() -> super.wrapCallable(callable)); }
public HystrixContextCallable(HystrixConcurrencyStrategy concurrencyStrategy, Callable<K> actual) { this.actual = concurrencyStrategy.wrapCallable(actual); this.parentThreadState = HystrixRequestContext.getContextForCurrentThread(); }
public HystrixContextRunnable(HystrixConcurrencyStrategy concurrencyStrategy, final Runnable actual) { this.actual = concurrencyStrategy.wrapCallable(new Callable<Void>() { @Override public Void call() throws Exception { actual.run(); return null; } }); this.parentThreadState = HystrixRequestContext.getContextForCurrentThread(); }
@Override public <T> Callable<T> wrapCallable(Callable<T> callable) { return existingConcurrencyStrategy != null ? existingConcurrencyStrategy .wrapCallable(new DelegatingSecurityContextCallable<T>(callable)) : super.wrapCallable(new DelegatingSecurityContextCallable<T>(callable)); } }
@Override public <T> Callable<T> wrapCallable(final Callable<T> callable) { return delegate().wrapCallable(callable); }
@Override public <T> Callable<T> wrapCallable(Callable<T> callable) { if (callable instanceof TraceCallable) { return callable; } Callable<T> wrappedCallable = this.delegate != null ? this.delegate.wrapCallable(callable) : callable; if (wrappedCallable instanceof TraceCallable) { return wrappedCallable; } return new TraceCallable<>(this.tracing, this.spanNamer, wrappedCallable, HYSTRIX_COMPONENT); }
public HystrixContexSchedulerAction(final HystrixConcurrencyStrategy concurrencyStrategy, Action0 action) { this.actual = action; this.parentThreadState = HystrixRequestContext.getContextForCurrentThread(); this.c = concurrencyStrategy.wrapCallable(new Callable<Void>() { @Override public Void call() throws Exception { HystrixRequestContext existingState = HystrixRequestContext.getContextForCurrentThread(); try { // set the state of this thread to that of its parent HystrixRequestContext.setContextOnCurrentThread(parentThreadState); // execute actual Action0 with the state of the parent actual.call(); return null; } finally { // restore this thread back to its original state HystrixRequestContext.setContextOnCurrentThread(existingState); } } }); }
@Override public <T> Callable<T> wrapCallable(Callable<T> callable) { CustomCallable<T> customCallable = new CustomCallable<T>(callable, TraceIdHelper.getTraceId(), TraceIdHelper.getRemoteIp() ); return super.wrapCallable( customCallable ); }