Java Code Examples for com.netflix.hystrix.strategy.concurrency.HystrixRequestContext#setContextOnCurrentThread()

The following examples show how to use com.netflix.hystrix.strategy.concurrency.HystrixRequestContext#setContextOnCurrentThread() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuthHystrixConcurrencyStrategy.java    From spring-cloud-shop with MIT License 5 votes vote down vote up
/**
 * Call v.
 *
 * @return the v
 * @throws Exception the exception
 */
@Override
public V call() throws Exception {
    HystrixRequestContext existingState = HystrixRequestContext.getContextForCurrentThread();
    try {
        HystrixRequestContext.setContextOnCurrentThread(this.hystrixRequestContext);
        return this.delegate.call();
    } finally {
        HystrixRequestContext.setContextOnCurrentThread(existingState);
    }
}
 
Example 2
Source File: ContextInducedBlock.java    From Poseidon with Apache License 2.0 5 votes vote down vote up
protected void initAllContext(Request request) {
    existingState = HystrixRequestContext.getContextForCurrentThread();
    RequestContext.initialize(parentContext);
    ServiceContext.initialize(serviceContextState);
    HystrixRequestContext.setContextOnCurrentThread(parentThreadState);
    if (mdcContext != null) {
        MDC.setContextMap(mdcContext);
    }
    // Parent thread span info is passed onto filter thread using Brave's ThreadLocal implementation
    if (serverSpan != null && serverSpan.getSpan() != null) {
        Brave.getServerSpanThreadBinder().setCurrentSpan(serverSpan);
    }
    startTrace(block, request);
}
 
Example 3
Source File: ContextInducedBlock.java    From Poseidon with Apache License 2.0 5 votes vote down vote up
protected void shutdownAllContext() {
    endTrace(block, success);
    RequestContext.shutDown();
    ServiceContext.shutDown();
    HystrixRequestContext.setContextOnCurrentThread(existingState);
    MDC.clear();
    Brave.getServerSpanThreadBinder().setCurrentSpan(null);
}