This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new d78ecf3 [ISSUE #2931]Resolve hystrix plugin configuration rules do
not take effect (#2990)
d78ecf3 is described below
commit d78ecf3eefa178be0b316d2aaf3f5c58f7fe9510
Author: zouchangfu <[email protected]>
AuthorDate: Wed Mar 9 11:06:15 2022 +0800
[ISSUE #2931]Resolve hystrix plugin configuration rules do not take effect
(#2990)
* Resolve hystrix plugin configuration rules do not take effect
* Resolve hystrix plugin configuration rules do not take effect
* Resolve hystrix plugin configuration rules do not take effect
* Resolve hystrix plugin configuration rules do not take effect
* Resolve hystrix plugin configuration rules do not take effect
* Resolve hystrix plugin configuration rules do not take effect
* Resolve hystrix plugin configuration rules do not take effect
* Resolve hystrix plugin configuration rules do not take effect
---
.../org/apache/shenyu/plugin/hystrix/command/Command.java | 6 ++++++
.../shenyu/plugin/hystrix/command/HystrixCommand.java | 5 +++++
.../plugin/hystrix/command/HystrixCommandOnThread.java | 5 +++++
.../plugin/hystrix/handler/HystrixPluginDataHandler.java | 13 ++++++++++++-
4 files changed, 28 insertions(+), 1 deletion(-)
diff --git
a/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/command/Command.java
b/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/command/Command.java
index 526f0bf..a2e77d6 100644
---
a/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/command/Command.java
+++
b/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/command/Command.java
@@ -105,4 +105,10 @@ public interface Command {
*/
URI getCallBackUri();
+ /**
+ * removeCommandKey rule data.
+ * @param commandKey commandKey
+ */
+ void removeCommandKey(String commandKey);
+
}
diff --git
a/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/command/HystrixCommand.java
b/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/command/HystrixCommand.java
index e357707..b1c76f7 100644
---
a/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/command/HystrixCommand.java
+++
b/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/command/HystrixCommand.java
@@ -87,4 +87,9 @@ public class HystrixCommand extends
HystrixObservableCommand<Void> implements Co
public URI getCallBackUri() {
return callBackUri;
}
+
+ @Override
+ public void removeCommandKey(final String commandKey) {
+ executionSemaphorePerCircuit.remove(commandKey);
+ }
}
diff --git
a/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/command/HystrixCommandOnThread.java
b/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/command/HystrixCommandOnThread.java
index fdeeaaa..acde211 100644
---
a/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/command/HystrixCommandOnThread.java
+++
b/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/command/HystrixCommandOnThread.java
@@ -84,4 +84,9 @@ public class HystrixCommandOnThread extends
HystrixCommand<Mono<Void>> implement
public URI getCallBackUri() {
return callBackUri;
}
+
+ @Override
+ public void removeCommandKey(final String commandKey) {
+ executionSemaphorePerCircuit.remove(commandKey);
+ }
}
diff --git
a/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/handler/HystrixPluginDataHandler.java
b/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/handler/HystrixPluginDataHandler.java
index bd90f50..959a81e 100644
---
a/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/handler/HystrixPluginDataHandler.java
+++
b/shenyu-plugin/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/handler/HystrixPluginDataHandler.java
@@ -26,6 +26,9 @@ import org.apache.shenyu.plugin.base.cache.CommonHandleCache;
import org.apache.shenyu.plugin.base.handler.PluginDataHandler;
import org.apache.shenyu.plugin.base.utils.BeanHolder;
import org.apache.shenyu.plugin.base.utils.CacheKeyUtils;
+import org.apache.shenyu.plugin.hystrix.builder.HystrixBuilder;
+import org.apache.shenyu.plugin.hystrix.command.Command;
+import org.apache.shenyu.plugin.hystrix.command.HystrixCommand;
import java.util.Optional;
import java.util.function.Supplier;
@@ -42,7 +45,15 @@ public class HystrixPluginDataHandler implements
PluginDataHandler {
HystrixPropertiesFactory.reset();
Optional.ofNullable(ruleData.getHandle()).ifPresent(rule -> {
HystrixHandle hystrixHandle =
GsonUtils.getInstance().fromJson(rule, HystrixHandle.class);
-
CACHED_HANDLE.get().cachedHandle(CacheKeyUtils.INST.getKey(ruleData),
hystrixHandle);
+ String key = CacheKeyUtils.INST.getKey(ruleData);
+
Optional.ofNullable(CACHED_HANDLE.get().obtainHandle(key)).ifPresent(hystrixHandleCache
-> {
+ if (hystrixHandleCache.getMaxConcurrentRequests() !=
hystrixHandle.getMaxConcurrentRequests()) {
+ String commandKey = hystrixHandle.getCommandKey();
+ Command command = new
HystrixCommand(HystrixBuilder.build(hystrixHandle), null, null, null);
+ command.removeCommandKey(commandKey);
+ }
+ });
+ CACHED_HANDLE.get().cachedHandle(key, hystrixHandle);
});
}