提交 8c29d5a8 编写于 作者: wu-sheng's avatar wu-sheng

Merge branch 'master' into 6.0

......@@ -34,8 +34,21 @@ public class HystrixConcurrencyStrategyInterceptor implements InstanceMethodsAro
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
return new SWHystrixConcurrencyStrategyWrapper((HystrixConcurrencyStrategy)ret);
Object ret) throws Throwable {
SWHystrixPluginsWrapperCache wrapperCache = (SWHystrixPluginsWrapperCache) objInst.getSkyWalkingDynamicField();
if (wrapperCache == null || wrapperCache.getSwHystrixConcurrencyStrategyWrapper() == null) {
synchronized (objInst) {
if (wrapperCache == null) {
wrapperCache = new SWHystrixPluginsWrapperCache();
objInst.setSkyWalkingDynamicField(wrapperCache);
}
if (wrapperCache.getSwHystrixConcurrencyStrategyWrapper() == null) {
wrapperCache.setSwHystrixConcurrencyStrategyWrapper(new SWHystrixConcurrencyStrategyWrapper((HystrixConcurrencyStrategy) ret));
}
}
}
return wrapperCache.getSwHystrixConcurrencyStrategyWrapper();
}
@Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
......
......@@ -40,7 +40,20 @@ public class HystrixPluginsInterceptor implements InstanceMethodsAroundIntercept
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
return new SWExecutionHookWrapper((HystrixCommandExecutionHook)ret);
SWHystrixPluginsWrapperCache wrapperCache = (SWHystrixPluginsWrapperCache) objInst.getSkyWalkingDynamicField();
if (wrapperCache == null || wrapperCache.getSwExecutionHookWrapper() == null) {
synchronized (objInst) {
if (wrapperCache == null) {
wrapperCache = new SWHystrixPluginsWrapperCache();
objInst.setSkyWalkingDynamicField(wrapperCache);
}
if (wrapperCache.getSwExecutionHookWrapper() == null) {
wrapperCache.setSwExecutionHookWrapper(new SWExecutionHookWrapper((HystrixCommandExecutionHook) ret));
}
}
}
return wrapperCache.getSwExecutionHookWrapper();
}
@Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
......
......@@ -36,7 +36,10 @@ public class SWHystrixConcurrencyStrategyWrapper extends HystrixConcurrencyStrat
@Override
public <T> Callable<T> wrapCallable(Callable<T> callable) {
return new WrappedCallable<T>(ContextManager.getRuntimeContext().capture(), super.wrapCallable(callable));
Callable<T> delegateCallable = delegate != null
? delegate.wrapCallable(callable)
: super.wrapCallable(callable);
return new WrappedCallable<T>(ContextManager.getRuntimeContext().capture(), delegateCallable);
}
static class WrappedCallable<T> implements Callable<T> {
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.plugin.hystrix.v1;
/**
* {@link SWHystrixPluginsWrapperCache} record the {@link SWExecutionHookWrapper} and {@link SWHystrixConcurrencyStrategyWrapper} object for
* storing in EnhancedInstance#dynamicField together.
*
* @author chenpengfei
*/
public class SWHystrixPluginsWrapperCache {
private volatile SWExecutionHookWrapper swExecutionHookWrapper;
private volatile SWHystrixConcurrencyStrategyWrapper swHystrixConcurrencyStrategyWrapper;
public SWExecutionHookWrapper getSwExecutionHookWrapper() {
return swExecutionHookWrapper;
}
public void setSwExecutionHookWrapper(SWExecutionHookWrapper swExecutionHookWrapper) {
this.swExecutionHookWrapper = swExecutionHookWrapper;
}
public SWHystrixConcurrencyStrategyWrapper getSwHystrixConcurrencyStrategyWrapper() {
return swHystrixConcurrencyStrategyWrapper;
}
public void setSwHystrixConcurrencyStrategyWrapper(SWHystrixConcurrencyStrategyWrapper swHystrixConcurrencyStrategyWrapper) {
this.swHystrixConcurrencyStrategyWrapper = swHystrixConcurrencyStrategyWrapper;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册