You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2023/02/01 06:40:02 UTC
[servicecomb-java-chassis] branch master updated: [SCB-2578] remove bizkeeper module (#3609)
This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new edc4df2b0 [SCB-2578] remove bizkeeper module (#3609)
edc4df2b0 is described below
commit edc4df2b035945cc25f9e5e9adbb3a51d229955c
Author: lbc97 <82...@users.noreply.github.com>
AuthorDate: Wed Feb 1 14:39:56 2023 +0800
[SCB-2578] remove bizkeeper module (#3609)
---
coverage-reports/pom.xml | 4 -
.../src/main/resources/microservice.yaml | 4 -
.../src/main/resources/microservice.yaml | 2 +-
demo/demo-schema/pom.xml | 4 -
.../src/main/resources/application.yml | 6 +-
.../demo/springmvc/SpringmvcClient.java | 2 -
.../client/CodeFirstRestTemplateSpringmvc.java | 40 --
.../springmvc/client/MockedFallbackExample.java | 36 --
.../demo/springmvc/client/TestBizkeeper.java | 68 ---
.../src/main/resources/microservice.yaml | 2 +-
.../src/main/resources/microservice.yaml | 2 +-
dependencies/bom/pom.xml | 5 -
distribution/pom.xml | 4 -
foundations/foundation-spi/pom.xml | 15 +
handlers/handler-bizkeeper/pom.xml | 70 ---
handlers/handler-bizkeeper/readme.MD | 1 -
.../apache/servicecomb/bizkeeper/BeansHolder.java | 32 --
.../servicecomb/bizkeeper/BizkeeperCommand.java | 111 -----
.../bizkeeper/BizkeeperExceptionUtils.java | 39 --
.../servicecomb/bizkeeper/BizkeeperHandler.java | 88 ----
.../bizkeeper/BizkeeperHandlerDelegate.java | 67 ---
.../bizkeeper/BizkeeperRequestContext.java | 40 --
.../apache/servicecomb/bizkeeper/CommandKey.java | 42 --
.../servicecomb/bizkeeper/Configuration.java | 239 ---------
.../bizkeeper/ConsumerBizkeeperCommand.java | 44 --
.../bizkeeper/ConsumerBizkeeperHandler.java | 49 --
.../bizkeeper/CustomizeCommandGroupKey.java | 53 --
.../servicecomb/bizkeeper/FallbackPolicy.java | 30 --
.../bizkeeper/FallbackPolicyManager.java | 58 ---
.../bizkeeper/FromCacheFallbackPolicy.java | 52 --
.../bizkeeper/HystrixCommandPropertiesExt.java | 553 ---------------------
.../bizkeeper/HystrixPropertiesStrategyExt.java | 54 --
.../bizkeeper/ProviderBizkeeperCommand.java | 44 --
.../bizkeeper/ProviderBizkeeperHanlder.java | 49 --
.../bizkeeper/ReturnNullFallbackPolicy.java | 36 --
.../bizkeeper/ThrowExceptionFallbackPolicy.java | 40 --
.../bizkeeper/event/CircutBreakerEvent.java | 113 -----
.../event/CircutBreakerEventNotifier.java | 61 ---
.../main/resources/META-INF/spring/cse.bean.xml | 24 -
.../src/main/resources/config/cse.handler.xml | 23 -
.../src/main/resources/hystrix-plugins.properties | 17 -
.../bizkeeper/TestBizkeeperCommand.java | 221 --------
.../bizkeeper/TestBizkeeperExceptionUtils.java | 34 --
.../bizkeeper/TestBizkeeperHandler.java | 193 -------
.../bizkeeper/TestBizkeeperRequestContext.java | 50 --
.../servicecomb/bizkeeper/TestCommandKey.java | 57 ---
.../servicecomb/bizkeeper/TestConfiguration.java | 59 ---
.../bizkeeper/TestConsumerBizkeeperHandler.java | 48 --
.../bizkeeper/TestCustomCommandGroupKey.java | 44 --
.../bizkeeper/TestFallbackPolicyManager.java | 104 ----
.../TestHystrixPropertiesStrategyExt.java | 78 ---
.../bizkeeper/TestProviderBizkeeperHandler.java | 48 --
.../event/TestCircutBreakerEventNotifier.java | 83 ----
handlers/pom.xml | 1 -
huawei-cloud/dashboard/pom.xml | 5 -
.../monitor/HealthMonitorDataProvider.java | 121 -----
.../monitor/MetricsMonitorDataProviderTest.java | 20 -
solutions/solution-basic/pom.xml | 4 -
.../java-chassis-spring-boot-starter/pom.xml | 4 -
59 files changed, 19 insertions(+), 3378 deletions(-)
diff --git a/coverage-reports/pom.xml b/coverage-reports/pom.xml
index 939661403..30777c015 100644
--- a/coverage-reports/pom.xml
+++ b/coverage-reports/pom.xml
@@ -170,10 +170,6 @@
</dependency>
<!-- handlers -->
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handler-bizkeeper</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>handler-fault-injection</artifactId>
diff --git a/demo/demo-jaxrs/jaxrs-server/src/main/resources/microservice.yaml b/demo/demo-jaxrs/jaxrs-server/src/main/resources/microservice.yaml
index f4f585ecc..d0d520d18 100644
--- a/demo/demo-jaxrs/jaxrs-server/src/main/resources/microservice.yaml
+++ b/demo/demo-jaxrs/jaxrs-server/src/main/resources/microservice.yaml
@@ -28,10 +28,6 @@ servicecomb:
maxFormAttributeSize: 1024
highway:
address: 0.0.0.0:7070
- handler:
- chain:
- Provider:
- default: bizkeeper-provider
uploads:
directory: target
diff --git a/demo/demo-pojo/pojo-client/src/main/resources/microservice.yaml b/demo/demo-pojo/pojo-client/src/main/resources/microservice.yaml
index fea413156..adc15a3e9 100644
--- a/demo/demo-pojo/pojo-client/src/main/resources/microservice.yaml
+++ b/demo/demo-pojo/pojo-client/src/main/resources/microservice.yaml
@@ -35,7 +35,7 @@ servicecomb:
handler:
chain:
Consumer:
- default: qps-flowcontrol-consumer,auth-consumer,bizkeeper-consumer,loadbalance
+ default: qps-flowcontrol-consumer,auth-consumer,loadbalance
isolation:
Consumer:
enabled: false
diff --git a/demo/demo-schema/pom.xml b/demo/demo-schema/pom.xml
index dbd4315d4..fe7daddc6 100644
--- a/demo/demo-schema/pom.xml
+++ b/demo/demo-schema/pom.xml
@@ -28,10 +28,6 @@
<dependencies>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handler-bizkeeper</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>handler-loadbalance</artifactId>
diff --git a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/src/main/resources/application.yml b/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/src/main/resources/application.yml
index 6f9757580..c13f2f8ed 100644
--- a/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/src/main/resources/application.yml
+++ b/demo/demo-spring-boot-provider/demo-spring-boot-jaxrs-server/src/main/resources/application.yml
@@ -31,8 +31,4 @@ servicecomb:
rest:
address: 0.0.0.0:8080
highway:
- address: 0.0.0.0:7070
- handler:
- chain:
- Provider:
- default: bizkeeper-provider
\ No newline at end of file
+ address: 0.0.0.0:7070
\ No newline at end of file
diff --git a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/SpringmvcClient.java b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/SpringmvcClient.java
index c15015835..0c7cbdb10 100644
--- a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/SpringmvcClient.java
+++ b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/SpringmvcClient.java
@@ -170,8 +170,6 @@ public class SpringmvcClient {
TestMgr.check(true,
content.contains(
"servicecomb_invocation{appId=\"" + application + "\",operation=\"springmvc.codeFirst.sayHello"));
- TestMgr.check(true, content.contains(
- "servicecomb_invocation{appId=\"" + application + "\",operation=\"springmvc.codeFirst.fallbackFromCache"));
TestMgr.check(true,
content
.contains("servicecomb_invocation{appId=\"" + application + "\",operation=\"springmvc.codeFirst.isTrue"));
diff --git a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/CodeFirstRestTemplateSpringmvc.java b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/CodeFirstRestTemplateSpringmvc.java
index f22675f8a..ddf1a0d49 100644
--- a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/CodeFirstRestTemplateSpringmvc.java
+++ b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/CodeFirstRestTemplateSpringmvc.java
@@ -29,7 +29,6 @@ import java.util.Map;
import javax.servlet.http.Part;
import org.apache.commons.io.FileUtils;
-import org.apache.servicecomb.bizkeeper.BizkeeperExceptionUtils;
import org.apache.servicecomb.demo.CodeFirstRestTemplate;
import org.apache.servicecomb.demo.TestMgr;
import org.apache.servicecomb.foundation.common.part.FilePart;
@@ -73,8 +72,6 @@ public class CodeFirstRestTemplateSpringmvc extends CodeFirstRestTemplate {
private TestContentType testContentType = new TestContentType();
- private TestBizkeeper testBizkeeper = new TestBizkeeper();
-
@Override
protected void testOnlyRest(String microservcieName, RestTemplate template, String cseUrlPrefix) {
try {
@@ -84,7 +81,6 @@ public class CodeFirstRestTemplateSpringmvc extends CodeFirstRestTemplate {
}
testResponseEntity("springmvc", template, cseUrlPrefix);
testCodeFirstTestFormRest(template, cseUrlPrefix);
- testFallback(template, cseUrlPrefix);
testResponse.runRest();
testObject.runRest();
@@ -110,10 +106,8 @@ public class CodeFirstRestTemplateSpringmvc extends CodeFirstRestTemplate {
testObject.runAllTransport();
testGeneric.runAllTransport();
testRestTemplate.runAllTest();
- testBizkeeper.runAllTest();
testResponseEntity("springmvc", template, cseUrlPrefix);
testCodeFirstTestForm(template, cseUrlPrefix);
- testFallback(template, cseUrlPrefix);
super.testAllTransport(microserviceName, template, cseUrlPrefix);
}
@@ -177,40 +171,6 @@ public class CodeFirstRestTemplateSpringmvc extends CodeFirstRestTemplate {
String.class);
}
- private void testFallback(RestTemplate template, String cseUrlPrefix) {
- long start = System.currentTimeMillis();
- String result = template.getForObject(cseUrlPrefix + "/fallback/returnnull/hello", String.class);
- TestMgr.check(result, "hello");
- result = template.getForObject(cseUrlPrefix + "/fallback/returnnull/throwexception", String.class);
- TestMgr.check(result, null);
-
- result = template.getForObject(cseUrlPrefix + "/fallback/throwexception/hello", String.class);
- TestMgr.check(result, "hello");
- try {
- result = template.getForObject(cseUrlPrefix + "/fallback/throwexception/throwexception", String.class);
- TestMgr.check(false, true);
- } catch (Exception e) {
- TestMgr.check(e.getCause().getMessage(),
- BizkeeperExceptionUtils.createBizkeeperException(BizkeeperExceptionUtils.SERVICECOMB_BIZKEEPER_FALLBACK,
- null,
- "springmvc.codeFirst.fallbackThrowException").getMessage());
- }
-
- result = template.getForObject(cseUrlPrefix + "/fallback/fromcache/hello", String.class);
- TestMgr.check(result, "hello");
- result = template.getForObject(cseUrlPrefix + "/fallback/fromcache/hello", String.class);
- TestMgr.check(result, "hello");
- result = template.getForObject(cseUrlPrefix + "/fallback/fromcache/throwexception", String.class);
- TestMgr.check(result, "hello");
-
- result = template.getForObject(cseUrlPrefix + "/fallback/force/hello", String.class);
- TestMgr.check(result, "mockedreslut");
-
- // This test case is fallback testing and will return null if failed.
- // In order to check if failed due to some unexpected timeout exception, check the time.
- TestMgr.check(System.currentTimeMillis() - start < 10000, true);
- }
-
private void testResponseEntity(String microserviceName, RestTemplate template, String cseUrlPrefix) {
Map<String, Object> body = new HashMap<>();
Date date = new Date();
diff --git a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/MockedFallbackExample.java b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/MockedFallbackExample.java
deleted file mode 100644
index 3533aed20..000000000
--- a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/MockedFallbackExample.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.servicecomb.demo.springmvc.client;
-
-import org.apache.servicecomb.bizkeeper.FallbackPolicy;
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.swagger.invocation.Response;
-import org.springframework.stereotype.Component;
-
-@Component
-public class MockedFallbackExample implements FallbackPolicy {
-
- @Override
- public String name() {
- return "mycustom";
- }
-
- @Override
- public Response getFallbackResponse(Invocation invocation, Throwable error) {
- return Response.succResp("mockedreslut");
- }
-}
diff --git a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestBizkeeper.java b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestBizkeeper.java
deleted file mode 100644
index 4b24f1cb3..000000000
--- a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestBizkeeper.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.servicecomb.demo.springmvc.client;
-
-import java.util.concurrent.TimeoutException;
-
-import org.apache.servicecomb.demo.TestMgr;
-import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
-import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
-import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
-import org.springframework.web.client.RestTemplate;
-
-public class TestBizkeeper {
- private RestTemplate restTemplate = RestTemplateBuilder.create();
-
- private String prefix = "cse://springmvc/codeFirstBizkeeperTest";
-
- public void runAllTest() {
- testTimeout();
- }
-
- private void testTimeout() {
- //config timeout starts with cse.xxx, from yaml
- try {
- restTemplate.getForObject(prefix + "/testTimeout?name={1}&delaytime={2}", String.class, "joker", 1000);
- } catch (Exception e) {
- TestMgr.check(TimeoutException.class, e.getCause().getCause().getClass());
- }
- //modify config timeout starts with servicecomb.xxx, can change the timeout effect
- ArchaiusUtils.setProperty(
- "servicecomb.isolation.Consumer.springmvc.codeFirstBizkeeperTest.testTimeout.timeout.enabled", "false");
- try {
- String result =
- restTemplate.getForObject(prefix + "/testTimeout?name={1}&delaytime={2}", String.class, "joker", 1000);
- TestMgr.check("joker", result);
- } catch (Exception e) {
- TestMgr.check("expect: not throw timeout exception", "real: throw timeout exception");
- }
-
- try {
- ArchaiusUtils.setProperty(
- "servicecomb.fallback.Consumer.springmvc.codeFirstBizkeeperTest.testTimeout.enabled", "false");
- ArchaiusUtils.setProperty(
- "servicecomb.isolation.Consumer.springmvc.codeFirstBizkeeperTest.testTimeout.timeout.enabled", "true");
- ArchaiusUtils.setProperty(
- "servicecomb.isolation.Consumer.springmvc.codeFirstBizkeeperTest.testTimeout.timeoutInMilliseconds", 500);
- restTemplate.getForObject(prefix + "/testTimeout?name={1}&delaytime={2}", String.class, "joker", 1000);
- TestMgr.check("expect: throw timeout exception", "real: not throw timeout exception");
- } catch (InvocationException e) {
- TestMgr.check(TimeoutException.class, e.getCause().getCause().getClass());
- }
- }
-}
diff --git a/demo/demo-springmvc/springmvc-client/src/main/resources/microservice.yaml b/demo/demo-springmvc/springmvc-client/src/main/resources/microservice.yaml
index d123e21f2..7d9707ac9 100644
--- a/demo/demo-springmvc/springmvc-client/src/main/resources/microservice.yaml
+++ b/demo/demo-springmvc/springmvc-client/src/main/resources/microservice.yaml
@@ -43,7 +43,7 @@ servicecomb:
handler:
chain:
Consumer:
- default: loadbalance,fault-injection-consumer,bizkeeper-consumer
+ default: loadbalance,fault-injection-consumer
invocation:
timeout:
check:
diff --git a/demo/demo-springmvc/springmvc-server/src/main/resources/microservice.yaml b/demo/demo-springmvc/springmvc-server/src/main/resources/microservice.yaml
index 5c76a8abd..8eab809a1 100644
--- a/demo/demo-springmvc/springmvc-server/src/main/resources/microservice.yaml
+++ b/demo/demo-springmvc/springmvc-server/src/main/resources/microservice.yaml
@@ -69,7 +69,7 @@ servicecomb:
handler:
chain:
Provider:
- default: test-provider, bizkeeper-provider, qps-flowcontrol-provider
+ default: test-provider, qps-flowcontrol-provider
flowcontrol:
strategy: MyStrategy
Provider:
diff --git a/dependencies/bom/pom.xml b/dependencies/bom/pom.xml
index 3c39c995d..0a9544959 100644
--- a/dependencies/bom/pom.xml
+++ b/dependencies/bom/pom.xml
@@ -203,11 +203,6 @@
</dependency>
<!-- ServiceComb: handlers -->
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handler-bizkeeper</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>handler-fault-injection</artifactId>
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 8156a4247..89aa35ba3 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -168,10 +168,6 @@
</dependency>
<!-- handlers -->
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handler-bizkeeper</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>handler-fault-injection</artifactId>
diff --git a/foundations/foundation-spi/pom.xml b/foundations/foundation-spi/pom.xml
index 1f1dc2b00..6c772304b 100644
--- a/foundations/foundation-spi/pom.xml
+++ b/foundations/foundation-spi/pom.xml
@@ -41,4 +41,19 @@
<scope>test</scope>
</dependency>
</dependencies>
+ <!--<build>
+ <plugins>
+ <!– 配置当前项目的jdk版本信息 –>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.1</version>
+ <configuration>
+ <source>17</source>
+ <target>17</target>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>-->
</project>
diff --git a/handlers/handler-bizkeeper/pom.xml b/handlers/handler-bizkeeper/pom.xml
deleted file mode 100644
index c69e3a684..000000000
--- a/handlers/handler-bizkeeper/pom.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<!--
- ~ 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.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handlers</artifactId>
- <version>2.9.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>handler-bizkeeper</artifactId>
- <name>Java Chassis::Handlers::Bizkeeper</name>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>java-chassis-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>foundation-metrics</artifactId>
- </dependency>
- <dependency>
- <groupId>com.netflix.hystrix</groupId>
- <artifactId>hystrix-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-inline</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>foundation-test-scaffolding</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/handlers/handler-bizkeeper/readme.MD b/handlers/handler-bizkeeper/readme.MD
deleted file mode 100644
index d5045ac07..000000000
--- a/handlers/handler-bizkeeper/readme.MD
+++ /dev/null
@@ -1 +0,0 @@
-参考: hystrix: https://github.com/Netflix/Hystrix/wiki
\ No newline at end of file
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BeansHolder.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BeansHolder.java
deleted file mode 100644
index 41f5efa56..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BeansHolder.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import java.util.List;
-
-import javax.inject.Inject;
-
-public class BeansHolder {
- @Inject
- private List<FallbackPolicy> policies;
-
- public void init() {
- for (FallbackPolicy policy : this.policies) {
- FallbackPolicyManager.addPolicy(policy);
- }
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperCommand.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperCommand.java
deleted file mode 100644
index ac64bbffe..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperCommand.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Const;
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.swagger.invocation.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.netflix.config.DynamicPropertyFactory;
-import com.netflix.hystrix.HystrixObservableCommand;
-import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
-
-import rx.Observable;
-
-/**
- * 接管调用链的处理流程,处理完成后,将结果交给调用链。额外还提供了请求缓存的功能和容错/降级处理能力。
- *
- */
-public abstract class BizkeeperCommand extends HystrixObservableCommand<Response> {
- private static final Logger LOG = LoggerFactory.getLogger(BizkeeperCommand.class);
-
- private final Invocation invocation;
-
- private final String type;
-
- protected BizkeeperCommand(String type, Invocation invocation, HystrixObservableCommand.Setter setter) {
- super(setter);
- this.type = type;
- this.invocation = invocation;
- }
-
- @Override
- protected String getCacheKey() {
- if (HystrixRequestContext.isCurrentThreadInitialized()) {
- StringBuilder sb = new StringBuilder();
- sb.append(this.getCommandGroup().name());
- sb.append("-");
- sb.append(this.getCommandKey().name());
- return sb.toString();
- } else {
- return super.getCacheKey();
- }
- }
-
- @Override
- protected Observable<Response> resumeWithFallback() {
- Throwable cause = getFailedExecutionException();
- Observable<Response> observable = Observable.unsafeCreate(f -> {
- try {
- f.onNext(FallbackPolicyManager.getFallbackResponse(type, cause, invocation));
- f.onCompleted();
- } catch (Exception e) {
- if (DynamicPropertyFactory.getInstance().getBooleanProperty(Const.PRINT_SENSITIVE_ERROR_MESSAGE,
- false).get()) {
- LOG.warn("fallback failed.", e);
- } else {
- LOG.warn("fallback failed due to: {}", e.getMessage());
- }
- throw e;
- }
- });
- return observable;
- }
-
- @Override
- protected Observable<Response> construct() {
- return Observable.unsafeCreate(f -> {
- try {
- invocation.next(resp -> {
- if (isFailedResponse(resp)) {
- LOG.warn("bizkeeper command {} failed, trace id {} result {}",
- invocation.getInvocationQualifiedName(),
- invocation.getTraceId(),
- resp.getResult());
- f.onError(resp.getResult());
- FallbackPolicyManager.record(type, invocation, resp, false);
- } else {
- f.onNext(resp);
- f.onCompleted();
- FallbackPolicyManager.record(type, invocation, resp, true);
- }
- });
- } catch (Exception e) {
- LOG.warn("bizkeeper command {} execute failed, trace id {}, cause {}",
- invocation.getInvocationQualifiedName(),
- invocation.getTraceId(),
- e.getClass().getName());
- f.onError(e);
- }
- });
- }
-
- protected abstract boolean isFailedResponse(Response resp);
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperExceptionUtils.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperExceptionUtils.java
deleted file mode 100644
index 5e496e9b7..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperExceptionUtils.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.exception.CseException;
-import org.apache.servicecomb.core.exception.ExceptionUtils;
-
-public class BizkeeperExceptionUtils extends ExceptionUtils {
- private BizkeeperExceptionUtils() {
- }
-
- public static final String SERVICECOMB_BIZKEEPER_FALLBACK = "servicecomb.bizkeeper.fallback";
-
- static {
- ERROR_DESC_MGR.register(SERVICECOMB_BIZKEEPER_FALLBACK,
- "This is a fallback call from circuit breaker. "
- + "\n You can add fallback logic by catching this exception. " + "\n info: operation=%s.");
- }
-
- public static CseException createBizkeeperException(String code, Throwable cause, Object... args) {
- String msg = String.format(ERROR_DESC_MGR.ensureFindValue(code), args);
- return new CseException(code, msg, cause);
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperHandler.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperHandler.java
deleted file mode 100644
index dcb9ffc06..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperHandler.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Handler;
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.foundation.common.utils.ExceptionUtils;
-import org.apache.servicecomb.swagger.invocation.AsyncResponse;
-import org.apache.servicecomb.swagger.invocation.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.netflix.hystrix.HystrixCommandProperties;
-import com.netflix.hystrix.HystrixInvokable;
-import com.netflix.hystrix.HystrixObservable;
-import com.netflix.hystrix.strategy.HystrixPlugins;
-import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook;
-
-import rx.Observable;
-
-/**
- * 提供createBizkeeperCommand抽象接口来创建不同的处理链实例。
- *
- */
-public abstract class BizkeeperHandler implements Handler {
- private static final Logger LOG = LoggerFactory.getLogger(BizkeeperHandler.class);
-
- protected final String groupname;
-
- static {
- try {
- HystrixPlugins.getInstance().registerPropertiesStrategy(HystrixPropertiesStrategyExt.getInstance());
- } catch (IllegalStateException e) {
- LOG.warn("Hystrix properties already registered. Dynamic configuration may not work.", e);
- }
- try {
- HystrixPlugins.getInstance().registerCommandExecutionHook(new HystrixCommandExecutionHook() {
- @Override
- public <T> Exception onExecutionError(HystrixInvokable<T> commandInstance, Exception e) {
- LOG.warn("bizkeeper execution error, info={}", ExceptionUtils.getExceptionMessageWithoutTrace(e));
- return e; //by default, just pass through
- }
- });
- } catch (IllegalStateException e) {
- LOG.warn("HystrixCommandExecutionHook already registered.", e);
- }
- }
-
- private final BizkeeperHandlerDelegate delegate;
-
- public BizkeeperHandler(String groupname) {
- this.groupname = groupname;
- delegate = new BizkeeperHandlerDelegate(this);
- }
-
- protected abstract BizkeeperCommand createBizkeeperCommand(Invocation invocation);
-
- @Override
- public void handle(Invocation invocation, AsyncResponse asyncResp) {
- HystrixObservable<Response> command = delegate.createBizkeeperCommand(invocation);
-
- Observable<Response> observable = command.toObservable();
- observable.subscribe(asyncResp::complete, error -> {
- LOG.warn("catch error in bizkeeper:" + error.getMessage());
- asyncResp.fail(invocation.getInvocationType(), error);
- }, () -> {
-
- });
- }
-
- protected void setCommonProperties(Invocation invocation, HystrixCommandProperties.Setter setter) {
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperHandlerDelegate.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperHandlerDelegate.java
deleted file mode 100644
index 389fc0414..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperHandlerDelegate.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.swagger.invocation.Response;
-
-import com.netflix.hystrix.HystrixObservable;
-
-import rx.Observable;
-import rx.Subscription;
-import rx.subjects.ReplaySubject;
-
-public class BizkeeperHandlerDelegate {
-
- private final BizkeeperHandler handler;
-
- public BizkeeperHandlerDelegate(BizkeeperHandler handler) {
- this.handler = handler;
- }
-
- protected HystrixObservable<Response> createBizkeeperCommand(Invocation invocation) {
- if (Configuration.INSTANCE.isFallbackForce(handler.groupname,
- invocation.getMicroserviceName(),
- invocation.getOperationMeta().getMicroserviceQualifiedName())) {
- return forceFallbackCommand(invocation);
- }
- return handler.createBizkeeperCommand(invocation);
- }
-
- protected HystrixObservable<Response> forceFallbackCommand(Invocation invocation) {
- return new HystrixObservable<Response>() {
- @Override
- public Observable<Response> observe() {
- ReplaySubject<Response> subject = ReplaySubject.create();
- final Subscription sourceSubscription = toObservable().subscribe(subject);
- return subject.doOnUnsubscribe(sourceSubscription::unsubscribe);
- }
-
- @Override
- public Observable<Response> toObservable() {
- return Observable.unsafeCreate(f -> {
- try {
- f.onNext(FallbackPolicyManager.getFallbackResponse(handler.groupname, null, invocation));
- } catch (Exception e) {
- f.onError(e);
- }
- });
- }
- };
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperRequestContext.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperRequestContext.java
deleted file mode 100644
index ddab1369a..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/BizkeeperRequestContext.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
-
-/**
- * 使用缓存功能的时候,需要首先使用BizkeeperRequestContext来初始化上下文
- *
- */
-public final class BizkeeperRequestContext {
- private final HystrixRequestContext context;
-
- private BizkeeperRequestContext(HystrixRequestContext context) {
- this.context = context;
- }
-
- public static BizkeeperRequestContext initializeContext() {
- return new BizkeeperRequestContext(HystrixRequestContext.initializeContext());
- }
-
- public void shutdown() {
- this.context.shutdown();
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/CommandKey.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/CommandKey.java
deleted file mode 100644
index 22a2cfcdc..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/CommandKey.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-
-import com.netflix.hystrix.HystrixCommandGroupKey;
-import com.netflix.hystrix.HystrixCommandKey;
-
-/**
- * 创建对应的Key值
- *
- */
-public final class CommandKey {
- private CommandKey() {
- }
-
- public static HystrixCommandGroupKey toHystrixCommandGroupKey(String type, Invocation invocation) {
- return CustomizeCommandGroupKey.asKey(type + "." + invocation.getOperationMeta().getMicroserviceQualifiedName(),
- invocation);
- }
-
- public static HystrixCommandKey toHystrixCommandKey(String type, Invocation invocation) {
- return HystrixCommandKey.Factory
- .asKey(type + "." + invocation.getOperationMeta().getMicroserviceQualifiedName());
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/Configuration.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/Configuration.java
deleted file mode 100644
index 625bbdb46..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/Configuration.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import com.netflix.config.DynamicPropertyFactory;
-
-public final class Configuration {
- //isolation
- private static final String ISOLATION = "servicecomb.isolation.";
-
- private static final String ISOLATION_TIMEOUT_IN_MILLISECONDS = "timeoutInMilliseconds";
-
- private static final String ISOLATION_TIMEOUT_IN_MILLISECONDS_OLD =
- ".businessKeeper.command.execution.isolation.thread.timeoutInMilliseconds";
-
- private static final String ISOLATION_TIMEOUT_ENABLED = "timeout.enabled";
-
- private static final String ISOLATION_MAX_CONCURRENT_REQUESTS = "maxConcurrentRequests";
-
- //circuit breaker
- private static final String CIRCUIT_BREAKER = "servicecomb.circuitBreaker.";
-
- private static final String CIRCUIT_BREAKER_ENABLED = "enabled";
-
- private static final String CIRCUIT_BREAKER_FORCEOPEN = "forceOpen";
-
- private static final String CIRCUIT_BREAKER_FORCECLOSED = "forceClosed";
-
- private static final String CIRCUIT_BREAKER_SLEEP_WINDOW_IN_MILLISECONDS = "sleepWindowInMilliseconds";
-
- private static final String CIRCUIT_BREAKER_REQUEST_VOLUME_THRESHOLD = "requestVolumeThreshold";
-
- private static final String CIRCUIT_BREAKER_ERROR_THRESHOLD_PERCENTAGE = "errorThresholdPercentage";
-
- // fallback
- // following items only supports consumer
- private static final String FALLBACK = "servicecomb.fallback.";
-
- private static final String FALLBACK_FORCE = "force";
-
- private static final String FALLBACK_MAX_CONCURRENT_REQUESTS = "maxConcurrentRequests";
-
- // fallbackpolicy
- private static final String FALLBACKPOLICY = "servicecomb.fallbackpolicy.";
-
- private static final String FALLBACKPOLICY_POLICY = "policy";
-
- public static final String FALLBACKPOLICY_POLICY_THROW = "throwexception";
-
- public static final String FALLBACKPOLICY_POLICY_RETURN = "returnnull";
-
- private static final int DEFAULT_ISOLATION_TIMEOUT = 30000;
-
- private static final int DEFAULT_MAX_CONCURRENT_REQUESTS = 1000;
-
- private static final int DEFAULT_SLEEP_WINDOW = 15000;
-
- private static final int DEFAULT_VOLUME_THRESHOLD = 20;
-
- private static final int DEFAULT_THRESHOLD_PERCENTAGE = 50;
-
- public static final Configuration INSTANCE = new Configuration();
-
- private Configuration() {
-
- }
-
- public int getIsolationTimeoutInMilliseconds(String type, String microserviceName,
- String qualifiedOperationName) {
- int timeout;
- String p = getProperty("30000",
- ISOLATION + type + "." + qualifiedOperationName + "." + ISOLATION_TIMEOUT_IN_MILLISECONDS,
- ISOLATION + type + "." + microserviceName + "." + ISOLATION_TIMEOUT_IN_MILLISECONDS,
- ISOLATION + type + "." + ISOLATION_TIMEOUT_IN_MILLISECONDS,
- // 2.0 compatible
- type + "." + microserviceName + ISOLATION_TIMEOUT_IN_MILLISECONDS_OLD,
- type + ".default" + ISOLATION_TIMEOUT_IN_MILLISECONDS_OLD);
- try {
- timeout = Integer.parseInt(p);
- } catch (NumberFormatException e) {
- return DEFAULT_ISOLATION_TIMEOUT;
- }
- if (timeout > 0) {
- return timeout;
- }
- return DEFAULT_ISOLATION_TIMEOUT;
- }
-
- public boolean getIsolationTimeoutEnabled(String type, String microserviceName,
- String qualifiedOperationName) {
- String p = getProperty("false",
- ISOLATION + type + "." + qualifiedOperationName + "." + ISOLATION_TIMEOUT_ENABLED,
- ISOLATION + type + "." + microserviceName + "." + ISOLATION_TIMEOUT_ENABLED,
- ISOLATION + type + "." + ISOLATION_TIMEOUT_ENABLED);
- return Boolean.parseBoolean(p);
- }
-
- public int getIsolationMaxConcurrentRequests(String type, String microserviceName,
- String qualifiedOperationName) {
- int concurrentRequests;
- String p = getProperty("1000",
- ISOLATION + type + "." + qualifiedOperationName + "." + ISOLATION_MAX_CONCURRENT_REQUESTS,
- ISOLATION + type + "." + microserviceName + "." + ISOLATION_MAX_CONCURRENT_REQUESTS,
- ISOLATION + type + "." + ISOLATION_MAX_CONCURRENT_REQUESTS);
- try {
- concurrentRequests = Integer.parseInt(p);
- } catch (NumberFormatException e) {
- return DEFAULT_MAX_CONCURRENT_REQUESTS;
- }
- if (concurrentRequests > 0) {
- return concurrentRequests;
- }
- return DEFAULT_MAX_CONCURRENT_REQUESTS;
- }
-
- public boolean isCircuitBreakerEnabled(String type, String microserviceName, String qualifiedOperationName) {
- String p = getProperty("true",
- CIRCUIT_BREAKER + type + "." + qualifiedOperationName + "." + CIRCUIT_BREAKER_ENABLED,
- CIRCUIT_BREAKER + type + "." + microserviceName + "." + CIRCUIT_BREAKER_ENABLED,
- CIRCUIT_BREAKER + type + "." + CIRCUIT_BREAKER_ENABLED);
- return Boolean.parseBoolean(p);
- }
-
- public boolean isCircuitBreakerForceOpen(String type, String microserviceName, String qualifiedOperationName) {
- String p = getProperty("false",
- CIRCUIT_BREAKER + type + "." + qualifiedOperationName + "." + CIRCUIT_BREAKER_FORCEOPEN,
- CIRCUIT_BREAKER + type + "." + microserviceName + "." + CIRCUIT_BREAKER_FORCEOPEN,
- CIRCUIT_BREAKER + type + "." + CIRCUIT_BREAKER_FORCEOPEN);
- return Boolean.parseBoolean(p);
- }
-
- public boolean isCircuitBreakerForceClosed(String type, String microserviceName, String qualifiedOperationName) {
- String p = getProperty("false",
- CIRCUIT_BREAKER + type + "." + qualifiedOperationName + "." + CIRCUIT_BREAKER_FORCECLOSED,
- CIRCUIT_BREAKER + type + "." + microserviceName + "." + CIRCUIT_BREAKER_FORCECLOSED,
- CIRCUIT_BREAKER + type + "." + CIRCUIT_BREAKER_FORCECLOSED);
- return Boolean.parseBoolean(p);
- }
-
- public int getCircuitBreakerSleepWindowInMilliseconds(String type, String microserviceName,
- String qualifiedOperationName) {
- String p = getProperty("15000",
- CIRCUIT_BREAKER + type + "." + qualifiedOperationName + "."
- + CIRCUIT_BREAKER_SLEEP_WINDOW_IN_MILLISECONDS,
- CIRCUIT_BREAKER + type + "." + microserviceName + "." + CIRCUIT_BREAKER_SLEEP_WINDOW_IN_MILLISECONDS,
- CIRCUIT_BREAKER + type + "." + CIRCUIT_BREAKER_SLEEP_WINDOW_IN_MILLISECONDS);
- try {
- return Integer.parseInt(p);
- } catch (NumberFormatException e) {
- return DEFAULT_SLEEP_WINDOW;
- }
- }
-
- public int getCircuitBreakerRequestVolumeThreshold(String type, String microserviceName,
- String qualifiedOperationName) {
- String p = getProperty("20",
- CIRCUIT_BREAKER + type + "." + qualifiedOperationName + "."
- + CIRCUIT_BREAKER_REQUEST_VOLUME_THRESHOLD,
- CIRCUIT_BREAKER + type + "." + microserviceName + "." + CIRCUIT_BREAKER_REQUEST_VOLUME_THRESHOLD,
- CIRCUIT_BREAKER + type + "." + CIRCUIT_BREAKER_REQUEST_VOLUME_THRESHOLD);
- try {
- return Integer.parseInt(p);
- } catch (NumberFormatException e) {
- return DEFAULT_VOLUME_THRESHOLD;
- }
- }
-
- public int getCircuitBreakerErrorThresholdPercentage(String type, String microserviceName,
- String qualifiedOperationName) {
- String p = getProperty("50",
- CIRCUIT_BREAKER + type + "." + qualifiedOperationName + "."
- + CIRCUIT_BREAKER_ERROR_THRESHOLD_PERCENTAGE,
- CIRCUIT_BREAKER + type + "." + microserviceName + "." + CIRCUIT_BREAKER_ERROR_THRESHOLD_PERCENTAGE,
- CIRCUIT_BREAKER + type + "." + CIRCUIT_BREAKER_ERROR_THRESHOLD_PERCENTAGE);
- try {
- return Integer.parseInt(p);
- } catch (NumberFormatException e) {
- return DEFAULT_THRESHOLD_PERCENTAGE;
- }
- }
-
- public boolean isFallbackForce(String type, String microserviceName, String qualifiedOperationName) {
- String p = getProperty("false",
- FALLBACK + type + "." + qualifiedOperationName + "." + FALLBACK_FORCE,
- FALLBACK + type + "." + microserviceName + "." + FALLBACK_FORCE,
- FALLBACK + type + "." + FALLBACK_FORCE);
- return Boolean.parseBoolean(p);
- }
-
- public int getFallbackMaxConcurrentRequests(String type, String microserviceName, String qualifiedOperationName) {
- String p = getProperty("10",
- FALLBACK + type + "." + qualifiedOperationName + "." + FALLBACK_MAX_CONCURRENT_REQUESTS,
- FALLBACK + type + "." + microserviceName + "." + FALLBACK_MAX_CONCURRENT_REQUESTS,
- FALLBACK + type + "." + FALLBACK_MAX_CONCURRENT_REQUESTS);
- try {
- return Integer.parseInt(p);
- } catch (NumberFormatException e) {
- return DEFAULT_MAX_CONCURRENT_REQUESTS;
- }
- }
-
- public String getFallbackPolicyPolicy(String type, String microserviceName, String qualifiedOperationName) {
- return getProperty(null,
- FALLBACKPOLICY + type + "." + qualifiedOperationName + "." + FALLBACKPOLICY_POLICY,
- FALLBACKPOLICY + type + "." + microserviceName + "." + FALLBACKPOLICY_POLICY,
- FALLBACKPOLICY + type + "." + FALLBACKPOLICY_POLICY);
- }
-
- private String getProperty(String defaultValue, String... keys) {
- String property = null;
- for (String key : keys) {
- property = DynamicPropertyFactory.getInstance().getStringProperty(key, null).get();
- if (property != null) {
- break;
- }
- }
-
- if (property != null) {
- return property;
- } else {
- return defaultValue;
- }
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ConsumerBizkeeperCommand.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ConsumerBizkeeperCommand.java
deleted file mode 100644
index e43bfbd1e..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ConsumerBizkeeperCommand.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.swagger.invocation.Response;
-import org.apache.servicecomb.swagger.invocation.exception.ExceptionFactory;
-import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
-
-public class ConsumerBizkeeperCommand extends BizkeeperCommand {
- protected ConsumerBizkeeperCommand(String type, Invocation invocation,
- com.netflix.hystrix.HystrixObservableCommand.Setter setter) {
- super(type, invocation, setter);
- }
-
- @Override
- protected boolean isFailedResponse(Response resp) {
- if (resp.isFailed()) {
- if (InvocationException.class.isInstance(resp.getResult())) {
- InvocationException e = (InvocationException) resp.getResult();
- return e.getStatusCode() == ExceptionFactory.CONSUMER_INNER_STATUS_CODE;
- } else {
- return true;
- }
- } else {
- return false;
- }
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ConsumerBizkeeperHandler.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ConsumerBizkeeperHandler.java
deleted file mode 100644
index b665cd3a9..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ConsumerBizkeeperHandler.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-
-import com.netflix.hystrix.HystrixCommandProperties;
-import com.netflix.hystrix.HystrixObservableCommand;
-
-/**
- * 客户端调用链处理流程
- *
- */
-public class ConsumerBizkeeperHandler extends BizkeeperHandler {
- private static final String COMMAND_GROUP = "Consumer";
-
- public ConsumerBizkeeperHandler() {
- super(COMMAND_GROUP);
- }
-
- @Override
- protected BizkeeperCommand createBizkeeperCommand(Invocation invocation) {
- HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
- .withRequestCacheEnabled(true)
- .withRequestLogEnabled(false);
- setCommonProperties(invocation, setter);
-
- return new ConsumerBizkeeperCommand(groupname, invocation,
- HystrixObservableCommand.Setter
- .withGroupKey(CommandKey.toHystrixCommandGroupKey(groupname, invocation))
- .andCommandKey(CommandKey.toHystrixCommandKey(groupname, invocation))
- .andCommandPropertiesDefaults(setter));
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/CustomizeCommandGroupKey.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/CustomizeCommandGroupKey.java
deleted file mode 100644
index 63165eb33..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/CustomizeCommandGroupKey.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-
-import com.netflix.hystrix.HystrixCommandGroupKey;
-import com.netflix.hystrix.HystrixKey;
-import com.netflix.hystrix.util.InternMap;
-
-/**
- * 通过定制CommandGroupKey,目的是携带Invocation部分静态信息,便于CircutBreakerEvent获取
- */
-public class CustomizeCommandGroupKey extends HystrixKey.HystrixKeyDefault implements HystrixCommandGroupKey {
-
- private Invocation instance;
-
- public CustomizeCommandGroupKey(String key) {
- super(key);
- }
-
- private static final InternMap<String, CustomizeCommandGroupKey> intern =
- new InternMap<>(CustomizeCommandGroupKey::new);
-
- public static HystrixCommandGroupKey asKey(String key, Invocation invocation) {
- CustomizeCommandGroupKey result = intern.interned(key);
- result.setInvocation(invocation);
- return result;
- }
-
- public void setInvocation(Invocation invocation) {
- this.instance = invocation;
- }
-
- public Invocation getInstance() {
- return instance;
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/FallbackPolicy.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/FallbackPolicy.java
deleted file mode 100644
index c394a35d4..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/FallbackPolicy.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.swagger.invocation.Response;
-
-public interface FallbackPolicy {
- String name();
-
- Response getFallbackResponse(Invocation invocation, Throwable error);
-
- default void record(Invocation invocation, Response response, boolean isSuccess) {
-
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/FallbackPolicyManager.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/FallbackPolicyManager.java
deleted file mode 100644
index 03da31d3c..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/FallbackPolicyManager.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.swagger.invocation.Response;
-
-public class FallbackPolicyManager {
- private static final Map<String, FallbackPolicy> POLICIES = new HashMap<>();
-
- public static void addPolicy(FallbackPolicy policy) {
- POLICIES.put(policy.name().toLowerCase(), policy);
- }
-
- public static void record(String type, Invocation invocation, Response response, boolean isSuccess) {
- FallbackPolicy policy = getPolicy(type, invocation);
- if (policy != null) {
- policy.record(invocation, response, isSuccess);
- }
- }
-
- public static Response getFallbackResponse(String type, Throwable error, Invocation invocation) {
- FallbackPolicy policy = getPolicy(type, invocation);
- if (policy != null) {
- return policy.getFallbackResponse(invocation, error);
- } else {
- return Response.failResp(invocation.getInvocationType(), error);
- }
- }
-
- private static FallbackPolicy getPolicy(String type, Invocation invocation) {
- String policyKey = Configuration.INSTANCE.getFallbackPolicyPolicy(type,
- invocation.getMicroserviceName(),
- invocation.getOperationMeta().getMicroserviceQualifiedName());
- FallbackPolicy policy = null;
- if (policyKey != null) {
- policy = POLICIES.get(policyKey.toLowerCase());
- }
- return policy;
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/FromCacheFallbackPolicy.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/FromCacheFallbackPolicy.java
deleted file mode 100644
index 26c5b5d62..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/FromCacheFallbackPolicy.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.swagger.invocation.Response;
-import org.springframework.stereotype.Component;
-
-@Component
-public class FromCacheFallbackPolicy implements FallbackPolicy {
- private static final String POLICY_NAME = "fromCache";
-
- private final Map<String, Response> cachedResponse = new ConcurrentHashMap<>();
-
- @Override
- public String name() {
- return POLICY_NAME;
- }
-
- @Override
- public Response getFallbackResponse(Invocation invocation, Throwable error) {
- if (cachedResponse.get(invocation.getInvocationQualifiedName()) != null) {
- return cachedResponse.get(invocation.getInvocationQualifiedName());
- } else {
- return Response.succResp(null);
- }
- }
-
- @Override
- public void record(Invocation invocation, Response response, boolean isSuccess) {
- if (isSuccess) {
- cachedResponse.put(invocation.getInvocationQualifiedName(), response);
- }
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/HystrixCommandPropertiesExt.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/HystrixCommandPropertiesExt.java
deleted file mode 100644
index 406ecf111..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/HystrixCommandPropertiesExt.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/**
- * Copyright 2012 Netflix, Inc.
- *
- * Licensed 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.
- */
-
-// This file is forked from https://github.com/Netflix/Hystrix/blob/master/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandProperties.java
-
-package org.apache.servicecomb.bizkeeper;
-
-import static com.netflix.hystrix.strategy.properties.HystrixPropertiesChainedProperty.forBoolean;
-import static com.netflix.hystrix.strategy.properties.HystrixPropertiesChainedProperty.forInteger;
-import static com.netflix.hystrix.strategy.properties.HystrixPropertiesChainedProperty.forString;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.netflix.hystrix.HystrixCommandKey;
-import com.netflix.hystrix.HystrixCommandProperties;
-import com.netflix.hystrix.strategy.properties.HystrixDynamicProperty;
-import com.netflix.hystrix.strategy.properties.HystrixProperty;
-
-public class HystrixCommandPropertiesExt extends HystrixCommandProperties {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(HystrixCommandProperties.class);
-
- /* defaults */
- /* package */
- // default => statisticalWindow: 10000 = 10 seconds (and default of 10
- // buckets so each bucket is 1 second)
- static final Integer DEFAULT_METRICSROLLINGSTATISTICALWINDOW = 10000;
-
- // default => statisticalWindowBuckets: 10 = 10 buckets in a 10 second
- // window so each bucket is 1 second
- private static final Integer DEFAULT_METRICSROLLINGSTATISTICALWINDOWBUCKETS = 10;
-
- // default => statisticalWindowVolumeThreshold: 20 requests in 10 seconds
- // must occur before statistics matter
- private static final Integer DEFAULT_CIRCUITBREAKERREQUESTVOLUMETHRESHOLD = 20;
-
- // default => sleepWindow: 15000 = 15 seconds that we will sleep before trying
- // again after tripping the circuit
- private static final Integer DEFAULT_CIRCUITBREAKERSLEEPWINDOWINMILLISECONDS = 15000;
-
- // default => errorThresholdPercentage = 50 = if 50%+ of requests in 10
- // seconds are failures or latent then we will trip the circuit
- private static final Integer DEFAULT_CIRCUITBREAKERERRORTHRESHOLDPERCENTAGE = 50;
-
- // default => forceCircuitOpen = false (we want to allow traffic)
- private static final Boolean DEFAULT_CIRCUITBREAKERFORCEOPEN = false;
-
- /* package */
- // default => ignoreErrors = false
- static final Boolean DEFAULT_CIRCUITBREAKERFORCECLOSED = false;
-
- // default => executionTimeoutInMilliseconds: 30000 = 30 second
- private static final Integer DEFAULT_EXECUTIONTIMEOUTINMILLISECONDS = 30000;
-
- private static final Boolean DEFAULT_EXECUTIONTIMEOUTENABLED = false;
-
- private static final ExecutionIsolationStrategy DEFAULT_ISOLATIONSTRATEGY = ExecutionIsolationStrategy.SEMAPHORE;
-
- private static final Boolean DEFAULT_EXECUTIONISOLATIONTHREADINTERRUPTONTIMEOUT = true;
-
- private static final Boolean DEFAULT_METRICSROLLINGPERCENTILEENABLED = false;
-
- private static final Boolean DEFAULT_REQUESTCACHEENABLED = true;
-
- private static final Integer DEFAULT_FALLBACKISOLATIONSEMAPHOREMAXCONCURRENTREQUESTS = 10;
-
- private static final Boolean DEFAULT_FALLBACKENABLED = true;
-
- private static final Integer DEFAULT_EXECUTIONISOLATIONSEMAPHOREMAXCONCURRENTREQUESTS = 1000;
-
- private static final Boolean DEFAULT_REQUESTLOGENABLED = true;
-
- private static final Boolean DEFAULT_CIRCUITBREAKERENABLED = true;
-
- // default to 1 minute for RollingPercentile
- private static final Integer DEFAULT_METRICSROLLINGPERCENTILEWINDOW = 60000;
-
- // default to 6 buckets (10 seconds each in 60 second window)
- private static final Integer DEFAULT_METRICSROLLINGPERCENTILEWINDOWBUCKETS = 6;
-
- // default to 100 values max per bucket
- private static final Integer DEFAULT_METRICSROLLINGPERCENTILEBUCKETSIZE = 100;
-
- // default to 1000ms as max frequency between allowing snapshots of health
- // (error percentage etc)
- private static final Integer DEFAULT_METRICSHEALTHSNAPSHOTINTERVALINMILLISECONDS = 1000;
-
- private static final int COMMAND_KEY_LENGTH = 3;
-
- @SuppressWarnings("unused")
- private final HystrixCommandKey key;
-
- // number of requests that must be made within a statisticalWindow before
- // open/close decisions are made using stats
- private final HystrixProperty<Integer> circuitBreakerRequestVolumeThreshold;
-
- // milliseconds after tripping circuit before allowing retry
- private final HystrixProperty<Integer> circuitBreakerSleepWindowInMilliseconds;
-
- // Whether circuit breaker should be enabled.
- private final HystrixProperty<Boolean> circuitBreakerEnabled;
-
- // % of 'marks' that must be failed to trip the circuit
- private final HystrixProperty<Integer> circuitBreakerErrorThresholdPercentage;
-
- // a property to allow forcing the circuit open (stopping all requests)
- private final HystrixProperty<Boolean> circuitBreakerForceOpen;
-
- // a property to allow ignoring errors and therefore never trip 'open' (ie.
- // allow all traffic through)
- private final HystrixProperty<Boolean> circuitBreakerForceClosed;
-
- // Whether a command should be executed in a separate thread or not.
- private final HystrixProperty<ExecutionIsolationStrategy> executionIsolationStrategy;
-
- // Timeout value in milliseconds for a command
- private final HystrixProperty<Integer> executionTimeoutInMilliseconds;
-
- // Whether timeout should be triggered
- private final HystrixProperty<Boolean> executionTimeoutEnabled;
-
- // What thread-pool this command should run in (if running on a separate
- // thread).
- private final HystrixProperty<String> executionIsolationThreadPoolKeyOverride;
-
- // Number of permits for execution semaphore
- private final HystrixProperty<Integer> executionIsolationSemaphoreMaxConcurrentRequests;
-
- // Number of permits for fallback semaphore
- private final HystrixProperty<Integer> fallbackIsolationSemaphoreMaxConcurrentRequests;
-
- // Whether fallback should be attempted.
- private final HystrixProperty<Boolean> fallbackEnabled;
-
- // Whether an underlying Future/Thread (when runInSeparateThread == true)
- // should be interrupted after a timeout
- private final HystrixProperty<Boolean> executionIsolationThreadInterruptOnTimeout;
-
- // milliseconds back that will be tracked
- private final HystrixProperty<Integer> metricsRollingStatisticalWindowInMilliseconds;
-
- // number of buckets in the statisticalWindow
- private final HystrixProperty<Integer> metricsRollingStatisticalWindowBuckets;
-
- // Whether monitoring should be enabled (SLA and Tracers).
- private final HystrixProperty<Boolean> metricsRollingPercentileEnabled;
-
- // number of milliseconds that will be tracked in RollingPercentile
- private final HystrixProperty<Integer> metricsRollingPercentileWindowInMilliseconds;
-
- // number of buckets percentileWindow will be divided into
- private final HystrixProperty<Integer> metricsRollingPercentileWindowBuckets;
-
- // how many values will be stored in each percentileWindowBucket
- private final HystrixProperty<Integer> metricsRollingPercentileBucketSize;
-
- // time between health snapshots
- private final HystrixProperty<Integer> metricsHealthSnapshotIntervalInMilliseconds;
-
- // whether command request logging is enabled.
- private final HystrixProperty<Boolean> requestLogEnabled;
-
- // Whether request caching is enabled.
- private final HystrixProperty<Boolean> requestCacheEnabled;
-
- protected HystrixCommandPropertiesExt(HystrixCommandKey key) {
- this(key, HystrixCommandProperties.Setter(), "servicecomb");
- }
-
- protected HystrixCommandPropertiesExt(HystrixCommandKey key, HystrixCommandProperties.Setter builder) {
- this(key, builder, "servicecomb");
- }
-
- protected HystrixCommandPropertiesExt(HystrixCommandKey key, HystrixCommandProperties.Setter builder,
- String propertyPrefix) {
- super(key, builder, propertyPrefix);
- this.key = key;
- this.circuitBreakerEnabled = getProperty(propertyPrefix,
- "circuitBreaker",
- key,
- "enabled",
- builder.getCircuitBreakerEnabled(),
- DEFAULT_CIRCUITBREAKERENABLED);
- this.circuitBreakerRequestVolumeThreshold = getProperty(propertyPrefix,
- "circuitBreaker",
- key,
- "requestVolumeThreshold",
- builder.getCircuitBreakerRequestVolumeThreshold(),
- DEFAULT_CIRCUITBREAKERREQUESTVOLUMETHRESHOLD);
- this.circuitBreakerSleepWindowInMilliseconds = getProperty(propertyPrefix,
- "circuitBreaker",
- key,
- "sleepWindowInMilliseconds",
- builder.getCircuitBreakerSleepWindowInMilliseconds(),
- DEFAULT_CIRCUITBREAKERSLEEPWINDOWINMILLISECONDS);
- this.circuitBreakerErrorThresholdPercentage = getProperty(propertyPrefix,
- "circuitBreaker",
- key,
- "errorThresholdPercentage",
- builder.getCircuitBreakerErrorThresholdPercentage(),
- DEFAULT_CIRCUITBREAKERERRORTHRESHOLDPERCENTAGE);
- this.circuitBreakerForceOpen = getProperty(propertyPrefix,
- "circuitBreaker",
- key,
- "forceOpen",
- builder.getCircuitBreakerForceOpen(),
- DEFAULT_CIRCUITBREAKERFORCEOPEN);
- this.circuitBreakerForceClosed = getProperty(propertyPrefix,
- "circuitBreaker",
- key,
- "forceClosed",
- builder.getCircuitBreakerForceClosed(),
- DEFAULT_CIRCUITBREAKERFORCECLOSED);
- this.executionIsolationStrategy = getProperty(propertyPrefix,
- "isolation",
- key,
- "strategy",
- builder.getExecutionIsolationStrategy(),
- DEFAULT_ISOLATIONSTRATEGY);
- this.executionTimeoutInMilliseconds = getProperty(propertyPrefix,
- "isolation",
- key,
- "timeoutInMilliseconds",
- builder.getExecutionTimeoutInMilliseconds(),
- DEFAULT_EXECUTIONTIMEOUTINMILLISECONDS);
- this.executionTimeoutEnabled = getProperty(propertyPrefix,
- "isolation",
- key,
- "timeout.enabled",
- builder.getExecutionTimeoutEnabled(),
- DEFAULT_EXECUTIONTIMEOUTENABLED);
- this.executionIsolationThreadInterruptOnTimeout = getProperty(propertyPrefix,
- "isolation",
- key,
- "interruptOnTimeout",
- builder.getExecutionIsolationThreadInterruptOnTimeout(),
- DEFAULT_EXECUTIONISOLATIONTHREADINTERRUPTONTIMEOUT);
- this.executionIsolationSemaphoreMaxConcurrentRequests = getProperty(propertyPrefix,
- "isolation",
- key,
- "maxConcurrentRequests",
- builder.getExecutionIsolationSemaphoreMaxConcurrentRequests(),
- DEFAULT_EXECUTIONISOLATIONSEMAPHOREMAXCONCURRENTREQUESTS);
- this.fallbackIsolationSemaphoreMaxConcurrentRequests = getProperty(propertyPrefix,
- "fallback",
- key,
- "maxConcurrentRequests",
- builder.getFallbackIsolationSemaphoreMaxConcurrentRequests(),
- DEFAULT_FALLBACKISOLATIONSEMAPHOREMAXCONCURRENTREQUESTS);
- this.fallbackEnabled = getProperty(propertyPrefix,
- "fallback",
- key,
- "enabled",
- builder.getFallbackEnabled(),
- DEFAULT_FALLBACKENABLED);
- this.metricsRollingStatisticalWindowInMilliseconds = getProperty(propertyPrefix,
- "metrics",
- key,
- "rollingStats.timeInMilliseconds",
- builder.getMetricsRollingStatisticalWindowInMilliseconds(),
- DEFAULT_METRICSROLLINGSTATISTICALWINDOW);
- this.metricsRollingStatisticalWindowBuckets = getProperty(propertyPrefix,
- "metrics",
- key,
- "rollingStats.numBuckets",
- builder.getMetricsRollingStatisticalWindowBuckets(),
- DEFAULT_METRICSROLLINGSTATISTICALWINDOWBUCKETS);
- this.metricsRollingPercentileEnabled = getProperty(propertyPrefix,
- "metrics",
- key,
- "rollingPercentile.enabled",
- builder.getMetricsRollingPercentileEnabled(),
- DEFAULT_METRICSROLLINGPERCENTILEENABLED);
- this.metricsRollingPercentileWindowInMilliseconds = getProperty(propertyPrefix,
- "metrics",
- key,
- "rollingPercentile.timeInMilliseconds",
- builder.getMetricsRollingPercentileWindowInMilliseconds(),
- DEFAULT_METRICSROLLINGPERCENTILEWINDOW);
- this.metricsRollingPercentileWindowBuckets = getProperty(propertyPrefix,
- "metrics",
- key,
- "rollingPercentile.numBuckets",
- builder.getMetricsRollingPercentileWindowBuckets(),
- DEFAULT_METRICSROLLINGPERCENTILEWINDOWBUCKETS);
- this.metricsRollingPercentileBucketSize = getProperty(propertyPrefix,
- "metrics",
- key,
- "rollingPercentile.bucketSize",
- builder.getMetricsRollingPercentileBucketSize(),
- DEFAULT_METRICSROLLINGPERCENTILEBUCKETSIZE);
- this.metricsHealthSnapshotIntervalInMilliseconds = getProperty(propertyPrefix,
- "metrics",
- key,
- "healthSnapshot.intervalInMilliseconds",
- builder.getMetricsHealthSnapshotIntervalInMilliseconds(),
- DEFAULT_METRICSHEALTHSNAPSHOTINTERVALINMILLISECONDS);
- this.requestCacheEnabled = getProperty(propertyPrefix,
- "requestCache",
- key,
- "enabled",
- builder.getRequestCacheEnabled(),
- DEFAULT_REQUESTCACHEENABLED);
- this.requestLogEnabled = getProperty(propertyPrefix,
- "requestLog",
- key,
- "enabled",
- builder.getRequestLogEnabled(),
- DEFAULT_REQUESTLOGENABLED);
-
- // threadpool doesn't have a global override, only instance level makes
- // sense
- this.executionIsolationThreadPoolKeyOverride = forString()
- .add(propertyPrefix + ".command." + key.name() + ".threadPoolKeyOverride", null)
- .build();
- }
-
- @Override
- public HystrixProperty<Boolean> circuitBreakerEnabled() {
- return circuitBreakerEnabled;
- }
-
- @Override
- public HystrixProperty<Integer> circuitBreakerErrorThresholdPercentage() {
- return circuitBreakerErrorThresholdPercentage;
- }
-
- @Override
- public HystrixProperty<Boolean> circuitBreakerForceClosed() {
- return circuitBreakerForceClosed;
- }
-
- @Override
- public HystrixProperty<Boolean> circuitBreakerForceOpen() {
- return circuitBreakerForceOpen;
- }
-
- @Override
- public HystrixProperty<Integer> circuitBreakerRequestVolumeThreshold() {
- return circuitBreakerRequestVolumeThreshold;
- }
-
- @Override
- public HystrixProperty<Integer> circuitBreakerSleepWindowInMilliseconds() {
- return circuitBreakerSleepWindowInMilliseconds;
- }
-
- @Override
- public HystrixProperty<Integer> executionIsolationSemaphoreMaxConcurrentRequests() {
- return executionIsolationSemaphoreMaxConcurrentRequests;
- }
-
- @Override
- public HystrixProperty<ExecutionIsolationStrategy> executionIsolationStrategy() {
- return executionIsolationStrategy;
- }
-
- @Override
- public HystrixProperty<Boolean> executionIsolationThreadInterruptOnTimeout() {
- return executionIsolationThreadInterruptOnTimeout;
- }
-
- @Override
- public HystrixProperty<String> executionIsolationThreadPoolKeyOverride() {
- return executionIsolationThreadPoolKeyOverride;
- }
-
- @Override
- @Deprecated // prefer {@link #executionTimeoutInMilliseconds}
- public HystrixProperty<Integer> executionIsolationThreadTimeoutInMilliseconds() {
- return executionTimeoutInMilliseconds;
- }
-
- @Override
- public HystrixProperty<Integer> executionTimeoutInMilliseconds() {
- return executionIsolationThreadTimeoutInMilliseconds();
- }
-
- @Override
- public HystrixProperty<Boolean> executionTimeoutEnabled() {
- return executionTimeoutEnabled;
- }
-
- @Override
- public HystrixProperty<Integer> fallbackIsolationSemaphoreMaxConcurrentRequests() {
- return fallbackIsolationSemaphoreMaxConcurrentRequests;
- }
-
- @Override
- public HystrixProperty<Boolean> fallbackEnabled() {
- return fallbackEnabled;
- }
-
- @Override
- public HystrixProperty<Integer> metricsHealthSnapshotIntervalInMilliseconds() {
- return metricsHealthSnapshotIntervalInMilliseconds;
- }
-
- @Override
- public HystrixProperty<Integer> metricsRollingPercentileBucketSize() {
- return metricsRollingPercentileBucketSize;
- }
-
- @Override
- public HystrixProperty<Boolean> metricsRollingPercentileEnabled() {
- return metricsRollingPercentileEnabled;
- }
-
- @Override
- @Deprecated
- public HystrixProperty<Integer> metricsRollingPercentileWindow() {
- return metricsRollingPercentileWindowInMilliseconds;
- }
-
- @Override
- public HystrixProperty<Integer> metricsRollingPercentileWindowInMilliseconds() {
- return metricsRollingPercentileWindowInMilliseconds;
- }
-
- @Override
- public HystrixProperty<Integer> metricsRollingPercentileWindowBuckets() {
- return metricsRollingPercentileWindowBuckets;
- }
-
- @Override
- public HystrixProperty<Integer> metricsRollingStatisticalWindowInMilliseconds() {
- return metricsRollingStatisticalWindowInMilliseconds;
- }
-
- @Override
- public HystrixProperty<Integer> metricsRollingStatisticalWindowBuckets() {
- return metricsRollingStatisticalWindowBuckets;
- }
-
- @Override
- public HystrixProperty<Boolean> requestCacheEnabled() {
- return requestCacheEnabled;
- }
-
- @Override
- public HystrixProperty<Boolean> requestLogEnabled() {
- return requestLogEnabled;
- }
-
- private HystrixProperty<ExecutionIsolationStrategy> getProperty(String propertyPrefix, String command,
- HystrixCommandKey key, String instanceProperty, ExecutionIsolationStrategy builderOverrideValue,
- ExecutionIsolationStrategy defaultValue) {
- return new ExecutionIsolationStrategyHystrixProperty(builderOverrideValue, key, propertyPrefix, command,
- defaultValue, instanceProperty);
- }
-
- private static final class ExecutionIsolationStrategyHystrixProperty
- implements HystrixProperty<ExecutionIsolationStrategy> {
- private final HystrixDynamicProperty<String> property;
-
- private volatile ExecutionIsolationStrategy value;
-
- private final ExecutionIsolationStrategy defaultValue;
-
- private ExecutionIsolationStrategyHystrixProperty(ExecutionIsolationStrategy builderOverrideValue,
- HystrixCommandKey key, String propertyPrefix, String command, ExecutionIsolationStrategy defaultValue,
- String instanceProperty) {
- this.defaultValue = defaultValue;
- String overrideValue = null;
- if (builderOverrideValue != null) {
- overrideValue = builderOverrideValue.name();
- }
- property = forString()
- .add(propertyPrefix + "." + command + "." + key.name() + "." + instanceProperty, null)
- .add(propertyPrefix + "." + command + "." + serviceKey(key.name()) + "." + instanceProperty,
- overrideValue)
- .add(propertyPrefix + "." + command + "." + typeKey(key.name()) + "." + instanceProperty,
- defaultValue.name())
- .build();
-
- // initialize the enum value from the property
- parseProperty();
-
- // use a callback to handle changes so we only handle the parse cost
- // on updates rather than every fetch
- // when the property value changes we'll update the value
- property.addCallback(this::parseProperty);
- }
-
- @Override
- public ExecutionIsolationStrategy get() {
- return value;
- }
-
- private void parseProperty() {
- try {
- value = ExecutionIsolationStrategy.valueOf(property.get());
- } catch (Exception e) {
- LOGGER.error("Unable to derive ExecutionIsolationStrategy from property value: " + property.get(), e);
- // use the default value
- value = defaultValue;
- }
- }
- }
-
- private static String serviceKey(String key) {
- String[] keyparts = key.split("\\.", COMMAND_KEY_LENGTH);
- if (keyparts.length == COMMAND_KEY_LENGTH) {
- return keyparts[0] + "." + keyparts[1];
- }
- return key;
- }
-
- private static String typeKey(String key) {
- int index = key.indexOf(".");
- if (index > 0) {
- return key.substring(0, index);
- }
- return key;
- }
-
- private HystrixProperty<Integer> getProperty(String propertyPrefix, String command, HystrixCommandKey key,
- String instanceProperty, Integer builderOverrideValue,
- Integer defaultValue) {
- return forInteger()
- .add(propertyPrefix + "." + command + "." + key.name() + "." + instanceProperty, null)
- .add(propertyPrefix + "." + command + "." + serviceKey(key.name()) + "." + instanceProperty,
- null)
- .add(propertyPrefix + "." + command + "." + typeKey(key.name()) + "." + instanceProperty,
- builderOverrideValue == null ? defaultValue : builderOverrideValue)
- .build();
- }
-
- private HystrixProperty<Boolean> getProperty(String propertyPrefix, String command, HystrixCommandKey key,
- String instanceProperty, Boolean builderOverrideValue, Boolean defaultValue) {
- return forBoolean()
- .add(propertyPrefix + "." + command + "." + key.name() + "." + instanceProperty, null)
- .add(propertyPrefix + "." + command + "." + serviceKey(key.name()) + "." + instanceProperty,
- null)
- .add(propertyPrefix + "." + command + "." + typeKey(key.name()) + "." + instanceProperty,
- builderOverrideValue == null ? defaultValue : builderOverrideValue)
- .build();
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/HystrixPropertiesStrategyExt.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/HystrixPropertiesStrategyExt.java
deleted file mode 100644
index c862d1195..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/HystrixPropertiesStrategyExt.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import java.util.Map;
-
-import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
-
-import com.netflix.hystrix.HystrixCommandKey;
-import com.netflix.hystrix.HystrixCommandProperties;
-import com.netflix.hystrix.HystrixCommandProperties.Setter;
-import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy;
-
-/**
- * 定制HystrixPropertiesStrategy。 配置需要支持动态生效和调整, 默认的hystrix实现会根据CommonKey进行缓存。
- * CircuitBreake需要统计并记录请求数据,需要缓存并保证每个commandKey对应一个Breaker;单纯清理CommandKey无法动态生效。
- * 参考:HystrixCircuitBreaker.Factory.getInstance(commandKey, groupKey,
- * properties, metrics)
- *
- */
-public final class HystrixPropertiesStrategyExt extends HystrixPropertiesStrategy {
-
- private static final HystrixPropertiesStrategyExt INSTANCE = new HystrixPropertiesStrategyExt();
-
- private final Map<String, HystrixCommandProperties> commandPropertiesMap = new ConcurrentHashMapEx<>();
-
- private HystrixPropertiesStrategyExt() {
- }
-
- public static HystrixPropertiesStrategyExt getInstance() {
- return INSTANCE;
- }
-
- @Override
- public HystrixCommandProperties getCommandProperties(HystrixCommandKey commandKey, Setter builder) {
- return commandPropertiesMap.computeIfAbsent(commandKey.name(),
- key -> new HystrixCommandPropertiesExt(commandKey, builder));
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ProviderBizkeeperCommand.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ProviderBizkeeperCommand.java
deleted file mode 100644
index 4ef5a629e..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ProviderBizkeeperCommand.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.swagger.invocation.Response;
-import org.apache.servicecomb.swagger.invocation.exception.ExceptionFactory;
-import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
-
-public class ProviderBizkeeperCommand extends BizkeeperCommand {
- protected ProviderBizkeeperCommand(String type, Invocation invocation,
- com.netflix.hystrix.HystrixObservableCommand.Setter setter) {
- super(type, invocation, setter);
- }
-
- @Override
- protected boolean isFailedResponse(Response resp) {
- if (resp.isFailed()) {
- if (InvocationException.class.isInstance(resp.getResult())) {
- InvocationException e = (InvocationException) resp.getResult();
- return e.getStatusCode() == ExceptionFactory.PRODUCER_INNER_STATUS_CODE;
- } else {
- return true;
- }
- } else {
- return false;
- }
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ProviderBizkeeperHanlder.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ProviderBizkeeperHanlder.java
deleted file mode 100644
index ce8ca4a30..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ProviderBizkeeperHanlder.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-
-import com.netflix.hystrix.HystrixCommandProperties;
-import com.netflix.hystrix.HystrixObservableCommand;
-
-/**
- * 服务端调用链处理流程
- *
- */
-public class ProviderBizkeeperHanlder extends BizkeeperHandler {
- private static final String COMMAND_GROUP = "Provider";
-
- public ProviderBizkeeperHanlder() {
- super(COMMAND_GROUP);
- }
-
- @Override
- protected BizkeeperCommand createBizkeeperCommand(Invocation invocation) {
- HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
- .withRequestCacheEnabled(false)
- .withRequestLogEnabled(false);
- setCommonProperties(invocation, setter);
-
- return new ProviderBizkeeperCommand(groupname, invocation,
- HystrixObservableCommand.Setter
- .withGroupKey(CommandKey.toHystrixCommandGroupKey(groupname, invocation))
- .andCommandKey(CommandKey.toHystrixCommandKey(groupname, invocation))
- .andCommandPropertiesDefaults(setter));
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ReturnNullFallbackPolicy.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ReturnNullFallbackPolicy.java
deleted file mode 100644
index 1b4d6e0f4..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ReturnNullFallbackPolicy.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.swagger.invocation.Response;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ReturnNullFallbackPolicy implements FallbackPolicy {
- private static final String POLICY_NAME = "returnNull";
-
- @Override
- public String name() {
- return POLICY_NAME;
- }
-
- @Override
- public Response getFallbackResponse(Invocation invocation, Throwable error) {
- return Response.succResp(null);
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ThrowExceptionFallbackPolicy.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ThrowExceptionFallbackPolicy.java
deleted file mode 100644
index 1c74e4a4d..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/ThrowExceptionFallbackPolicy.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.swagger.invocation.Response;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ThrowExceptionFallbackPolicy implements FallbackPolicy {
- private static final String POLICY_NAME = "throwException";
-
- @Override
- public String name() {
- return POLICY_NAME;
- }
-
- @Override
- public Response getFallbackResponse(Invocation invocation, Throwable error) {
- return Response.failResp(invocation.getInvocationType(),
- BizkeeperExceptionUtils
- .createBizkeeperException(BizkeeperExceptionUtils.SERVICECOMB_BIZKEEPER_FALLBACK,
- error,
- invocation.getOperationMeta().getMicroserviceQualifiedName()));
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/event/CircutBreakerEvent.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/event/CircutBreakerEvent.java
deleted file mode 100644
index c9f7a8ed8..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/event/CircutBreakerEvent.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper.event;
-
-
-import org.apache.servicecomb.bizkeeper.CustomizeCommandGroupKey;
-import org.apache.servicecomb.foundation.common.event.AlarmEvent;
-
-import com.netflix.hystrix.HystrixCommandKey;
-import com.netflix.hystrix.HystrixCommandMetrics;
-
-public class CircutBreakerEvent extends AlarmEvent {
-
- private String role;
-
- private String microservice;
-
- private String schema;
-
- private String operation;
-
- //当前总请求数
- private long currentTotalRequest;
-
- //当前请求出错计数
- private long currentErrorCount;
-
- //当前请求出错百分比
- private long currentErrorPercentage;
-
- private int requestVolumeThreshold;
-
- private int sleepWindowInMilliseconds;
-
- private int errorThresholdPercentage;
-
- public CircutBreakerEvent(HystrixCommandKey commandKey, Type type) {
- super(type);
- HystrixCommandMetrics hystrixCommandMetrics = HystrixCommandMetrics.getInstance(commandKey);
- if (hystrixCommandMetrics != null) {
- if (hystrixCommandMetrics.getCommandGroup() instanceof CustomizeCommandGroupKey) {
- CustomizeCommandGroupKey customCommandGroupKey =
- (CustomizeCommandGroupKey) hystrixCommandMetrics.getCommandGroup();
- this.microservice = customCommandGroupKey.getInstance().getMicroserviceName();
- this.role = customCommandGroupKey.getInstance().getInvocationType().name();
- this.schema = customCommandGroupKey.getInstance().getSchemaId();
- this.operation = customCommandGroupKey.getInstance().getOperationName();
- }
- this.currentTotalRequest = hystrixCommandMetrics.getHealthCounts().getTotalRequests();
- this.currentErrorPercentage = hystrixCommandMetrics.getHealthCounts().getErrorCount();
- this.currentErrorCount = hystrixCommandMetrics.getHealthCounts().getErrorPercentage();
- this.requestVolumeThreshold = hystrixCommandMetrics.getProperties().circuitBreakerRequestVolumeThreshold().get();
- this.sleepWindowInMilliseconds =
- hystrixCommandMetrics.getProperties().circuitBreakerSleepWindowInMilliseconds().get();
- this.errorThresholdPercentage =
- hystrixCommandMetrics.getProperties().circuitBreakerErrorThresholdPercentage().get();
- }
- }
-
- public String getRole() {
- return role;
- }
-
- public String getMicroservice() {
- return microservice;
- }
-
- public String getSchema() {
- return schema;
- }
-
- public String getOperation() {
- return operation;
- }
-
- public long getCurrentTotalRequest() {
- return currentTotalRequest;
- }
-
- public long getCurrentErrorCount() {
- return currentErrorCount;
- }
-
- public long getCurrentErrorPercentage() {
- return currentErrorPercentage;
- }
-
- public int getRequestVolumeThreshold() {
- return requestVolumeThreshold;
- }
-
- public int getSleepWindowInMilliseconds() {
- return sleepWindowInMilliseconds;
- }
-
- public int getErrorThresholdPercentage() {
- return errorThresholdPercentage;
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/event/CircutBreakerEventNotifier.java b/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/event/CircutBreakerEventNotifier.java
deleted file mode 100644
index 6eaaea6d7..000000000
--- a/handlers/handler-bizkeeper/src/main/java/org/apache/servicecomb/bizkeeper/event/CircutBreakerEventNotifier.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper.event;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.servicecomb.foundation.common.event.EventManager;
-import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
-import org.apache.servicecomb.foundation.common.event.AlarmEvent.Type;
-
-import com.google.common.eventbus.EventBus;
-import com.netflix.hystrix.HystrixCommandKey;
-import com.netflix.hystrix.HystrixEventType;
-import com.netflix.hystrix.strategy.eventnotifier.HystrixEventNotifier;
-
-public class CircutBreakerEventNotifier extends HystrixEventNotifier {
-
- /**
- * 使用circuitFlag来记录被熔断的接口
- */
- private final ConcurrentHashMapEx<String, AtomicBoolean> circuitFlag = new ConcurrentHashMapEx<>();
-
- EventBus eventBus = EventManager.getEventBus();
-
- @Override
- public void markEvent(HystrixEventType eventType, HystrixCommandKey key) {
- String keyName = key.name();
- AtomicBoolean flag = circuitFlag.computeIfAbsent(keyName, k -> new AtomicBoolean());
- switch (eventType) {
- case SHORT_CIRCUITED:
- if (flag.compareAndSet(false, true)) {
- eventBus.post(new CircutBreakerEvent(key, Type.OPEN));
- }
- break;
-
- case SUCCESS:
- if (flag.compareAndSet(true, false)) {
- eventBus.post(new CircutBreakerEvent(key, Type.CLOSE));
- }
- break;
-
- default:
- break;
- }
- }
-}
diff --git a/handlers/handler-bizkeeper/src/main/resources/META-INF/spring/cse.bean.xml b/handlers/handler-bizkeeper/src/main/resources/META-INF/spring/cse.bean.xml
deleted file mode 100644
index a362a92fb..000000000
--- a/handlers/handler-bizkeeper/src/main/resources/META-INF/spring/cse.bean.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean class="org.apache.servicecomb.bizkeeper.BeansHolder" init-method="init"/>
-</beans>
diff --git a/handlers/handler-bizkeeper/src/main/resources/config/cse.handler.xml b/handlers/handler-bizkeeper/src/main/resources/config/cse.handler.xml
deleted file mode 100644
index 4253c44d8..000000000
--- a/handlers/handler-bizkeeper/src/main/resources/config/cse.handler.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- ~ 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.
- -->
-
-<config>
- <handler id="bizkeeper-consumer"
- class="org.apache.servicecomb.bizkeeper.ConsumerBizkeeperHandler"/>
- <handler id="bizkeeper-provider"
- class="org.apache.servicecomb.bizkeeper.ProviderBizkeeperHanlder"/>
-</config>
diff --git a/handlers/handler-bizkeeper/src/main/resources/hystrix-plugins.properties b/handlers/handler-bizkeeper/src/main/resources/hystrix-plugins.properties
deleted file mode 100644
index 74eb50f74..000000000
--- a/handlers/handler-bizkeeper/src/main/resources/hystrix-plugins.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# 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.
-#
-hystrix.plugin.HystrixEventNotifier.implementation=org.apache.servicecomb.bizkeeper.event.CircutBreakerEventNotifier
diff --git a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestBizkeeperCommand.java b/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestBizkeeperCommand.java
deleted file mode 100644
index e02935a40..000000000
--- a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestBizkeeperCommand.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.core.definition.OperationMeta;
-import org.apache.servicecomb.swagger.invocation.Response;
-import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-import com.netflix.hystrix.HystrixCommandProperties;
-import com.netflix.hystrix.HystrixObservableCommand;
-import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
-
-import rx.Observable;
-
-public class TestBizkeeperCommand {
-
- @Test
- public void testGetCacheKeyProvider() {
-
- Invocation invocation = Mockito.mock(Invocation.class);
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
- HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
- .withRequestCacheEnabled(true)
- .withRequestLogEnabled(false);
-
- BizkeeperCommand bizkeeperCommand = new ProviderBizkeeperCommand("groupname", invocation,
- HystrixObservableCommand.Setter
- .withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
- .andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
- .andCommandPropertiesDefaults(setter));
-
- String str = bizkeeperCommand.getCacheKey();
- Assertions.assertNull(str);
-
- Response resp = Mockito.mock(Response.class);
- Mockito.when(resp.isFailed()).thenReturn(false);
- Assertions.assertFalse(bizkeeperCommand.isFailedResponse(resp));
- Mockito.when(resp.isFailed()).thenReturn(true);
- InvocationException excp = Mockito.mock(InvocationException.class);
- Mockito.when(resp.getResult()).thenReturn(excp);
- Mockito.when(excp.getStatusCode()).thenReturn(400);
- Assertions.assertFalse(bizkeeperCommand.isFailedResponse(resp));
- Mockito.when(resp.getResult()).thenReturn(excp);
- Mockito.when(excp.getStatusCode()).thenReturn(590);
- Assertions.assertTrue(bizkeeperCommand.isFailedResponse(resp));
- }
-
- @Test
- public void testResumeWithFallbackProvider() {
-
- Invocation invocation = Mockito.mock(Invocation.class);
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
- HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
- .withRequestCacheEnabled(true)
- .withRequestLogEnabled(false);
-
- BizkeeperCommand bizkeeperCommand = new ProviderBizkeeperCommand("groupname", invocation,
- HystrixObservableCommand.Setter
- .withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
- .andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
- .andCommandPropertiesDefaults(setter));
-
- Observable<Response> observe = bizkeeperCommand.resumeWithFallback();
- Assertions.assertNotNull(observe);
- }
-
- @Test
- public void testConstructProvider() {
-
- Invocation invocation = Mockito.mock(Invocation.class);
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
- HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
- .withRequestCacheEnabled(true)
- .withRequestLogEnabled(false);
-
- BizkeeperCommand bizkeeperCommand = new ProviderBizkeeperCommand("groupname", invocation,
- HystrixObservableCommand.Setter
- .withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
- .andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
- .andCommandPropertiesDefaults(setter));
-
- Observable<Response> response = bizkeeperCommand.construct();
- Assertions.assertNotNull(response);
- }
-
- @Test
- public void testGetCacheKeyWithContextInitializedProvider() {
-
- Invocation invocation = Mockito.mock(Invocation.class);
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
- HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
- .withRequestCacheEnabled(true)
- .withRequestLogEnabled(false);
-
- BizkeeperCommand bizkeeperCommand = new ProviderBizkeeperCommand("groupname", invocation,
- HystrixObservableCommand.Setter
- .withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
- .andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
- .andCommandPropertiesDefaults(setter));
-
- HystrixRequestContext.initializeContext();
- String cacheKey = bizkeeperCommand.getCacheKey();
- Assertions.assertNotNull(cacheKey);
- }
-
- @Test
- public void testGetCacheKeyConsumer() {
-
- Invocation invocation = Mockito.mock(Invocation.class);
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
- HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
- .withRequestCacheEnabled(true)
- .withRequestLogEnabled(false);
-
- BizkeeperCommand bizkeeperCommand = new ConsumerBizkeeperCommand("groupname", invocation,
- HystrixObservableCommand.Setter
- .withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
- .andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
- .andCommandPropertiesDefaults(setter));
-
- String str = bizkeeperCommand.getCacheKey();
- Assertions.assertNull(str);
-
- Response resp = Mockito.mock(Response.class);
- Mockito.when(resp.isFailed()).thenReturn(false);
- Assertions.assertFalse(bizkeeperCommand.isFailedResponse(resp));
- Mockito.when(resp.isFailed()).thenReturn(true);
- InvocationException excp = Mockito.mock(InvocationException.class);
- Mockito.when(resp.getResult()).thenReturn(excp);
- Mockito.when(excp.getStatusCode()).thenReturn(400);
- Assertions.assertFalse(bizkeeperCommand.isFailedResponse(resp));
- Mockito.when(resp.getResult()).thenReturn(excp);
- Mockito.when(excp.getStatusCode()).thenReturn(490);
- Assertions.assertTrue(bizkeeperCommand.isFailedResponse(resp));
- }
-
- @Test
- public void testResumeWithFallbackConsumer() {
-
- Invocation invocation = Mockito.mock(Invocation.class);
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
- HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
- .withRequestCacheEnabled(true)
- .withRequestLogEnabled(false);
-
- BizkeeperCommand bizkeeperCommand = new ConsumerBizkeeperCommand("groupname", invocation,
- HystrixObservableCommand.Setter
- .withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
- .andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
- .andCommandPropertiesDefaults(setter));
-
- Observable<Response> observe = bizkeeperCommand.resumeWithFallback();
- Assertions.assertNotNull(observe);
- }
-
- @Test
- public void testConstructConsumer() {
-
- Invocation invocation = Mockito.mock(Invocation.class);
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
- HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
- .withRequestCacheEnabled(true)
- .withRequestLogEnabled(false);
-
- BizkeeperCommand bizkeeperCommand = new ConsumerBizkeeperCommand("groupname", invocation,
- HystrixObservableCommand.Setter
- .withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
- .andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
- .andCommandPropertiesDefaults(setter));
-
- Observable<Response> response = bizkeeperCommand.construct();
- Assertions.assertNotNull(response);
- }
-
- @Test
- public void testGetCacheKeyWithContextInitializedConsumer() {
-
- Invocation invocation = Mockito.mock(Invocation.class);
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
- HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
- .withRequestCacheEnabled(true)
- .withRequestLogEnabled(false);
-
- BizkeeperCommand bizkeeperCommand = new ConsumerBizkeeperCommand("groupname", invocation,
- HystrixObservableCommand.Setter
- .withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
- .andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
- .andCommandPropertiesDefaults(setter));
-
- HystrixRequestContext.initializeContext();
- String cacheKey = bizkeeperCommand.getCacheKey();
- Assertions.assertNotNull(cacheKey);
- }
-}
diff --git a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestBizkeeperExceptionUtils.java b/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestBizkeeperExceptionUtils.java
deleted file mode 100644
index 2fabcabac..000000000
--- a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestBizkeeperExceptionUtils.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.exception.CseException;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class TestBizkeeperExceptionUtils {
-
- @Test
- public void testCreateBizkeeperException() {
- Assertions.assertEquals("servicecomb.bizkeeper.fallback", BizkeeperExceptionUtils.SERVICECOMB_BIZKEEPER_FALLBACK);
- CseException cseException = BizkeeperExceptionUtils.createBizkeeperException("servicecomb.bizkeeper.fallback",
- new Throwable(),
- "ARGS");
- Assertions.assertNotNull(cseException);
- }
-}
diff --git a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestBizkeeperHandler.java b/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestBizkeeperHandler.java
deleted file mode 100644
index 819f5bf8e..000000000
--- a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestBizkeeperHandler.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.core.definition.OperationMeta;
-import org.apache.servicecomb.swagger.invocation.AsyncResponse;
-import org.apache.servicecomb.swagger.invocation.InvocationType;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-import org.mockito.stubbing.Answer;
-
-import com.netflix.hystrix.HystrixCommandProperties;
-import com.netflix.hystrix.HystrixObservableCommand;
-import com.netflix.hystrix.strategy.HystrixPlugins;
-
-public class TestBizkeeperHandler extends BizkeeperHandler {
-
- BizkeeperHandler bizkeeperHandler = null;
-
- private static final String GROUP_NAME = "Group_Name";
-
- Invocation invocation = null;
-
- AsyncResponse asyncResp = null;
-
- public TestBizkeeperHandler() {
- super(GROUP_NAME);
- }
-
- @BeforeEach
- public void setUp() throws Exception {
- bizkeeperHandler = new TestBizkeeperHandler();
- invocation = Mockito.mock(Invocation.class);
- asyncResp = Mockito.mock(AsyncResponse.class);
-
- FallbackPolicyManager.addPolicy(new ReturnNullFallbackPolicy());
- FallbackPolicyManager.addPolicy(new ThrowExceptionFallbackPolicy());
- FallbackPolicyManager.addPolicy(new FromCacheFallbackPolicy());
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- bizkeeperHandler = null;
- invocation = null;
- asyncResp = null;
- }
-
- @Test
- public void testHandleWithException() {
- boolean validAssert;
- HystrixPlugins.reset();
- try {
- validAssert = true;
- bizkeeperHandler.handle(invocation, asyncResp);
- } catch (Exception e) {
- validAssert = false;
- }
- Assertions.assertFalse(validAssert);
- }
-
- @Test
- public void testHandle() {
- boolean validAssert;
-
- try {
- Assertions.assertNotNull(bizkeeperHandler);
- Mockito.when(invocation.getMicroserviceName()).thenReturn("test1");
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
- validAssert = true;
-
- bizkeeperHandler.handle(invocation, asyncResp);
- } catch (Exception exce) {
- validAssert = false;
- }
- Assertions.assertTrue(validAssert);
- }
-
- @Test
- public void testSetCommonProperties() {
- boolean validAssert;
- try {
- validAssert = true;
- HystrixPlugins.reset();
- HystrixCommandProperties.Setter setter = Mockito.mock(HystrixCommandProperties.Setter.class);
- bizkeeperHandler.setCommonProperties(invocation, setter);
- } catch (Exception e) {
- validAssert = false;
- }
- Assertions.assertTrue(validAssert);
- }
-
- @Override
- protected BizkeeperCommand createBizkeeperCommand(Invocation invocation) {
- HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
- .withRequestCacheEnabled(true)
- .withRequestLogEnabled(false);
-
- return new ConsumerBizkeeperCommand("groupname", invocation,
- HystrixObservableCommand.Setter
- .withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation))
- .andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation))
- .andCommandPropertiesDefaults(setter));
- }
-
- @Test
- public void testHandleForceThrowException() throws Exception {
- Mockito.when(invocation.getMicroserviceName()).thenReturn("testHandleForceThrowException");
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName())
- .thenReturn("testHandleForceThrowException");
- System.setProperty("servicecomb.fallback.Group_Name.testHandleForceThrowException.force", "true");
- System.setProperty("servicecomb.fallbackpolicy.Group_Name.testHandleForceThrowException.policy", "throwexception");
- bizkeeperHandler.handle(invocation, f -> Assertions.assertTrue(f.isFailed()));
- }
-
- @Test
- public void testHandleForceReturnnull() throws Exception {
- Mockito.when(invocation.getMicroserviceName()).thenReturn("testHandleForceReturnnull");
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName())
- .thenReturn("testHandleForceReturnnull");
- System.setProperty("servicecomb.fallback.Group_Name.testHandleForceReturnnull.force", "true");
- System.setProperty("servicecomb.fallbackpolicy.Group_Name.testHandleForceReturnnull.policy", "returnnull");
- bizkeeperHandler.handle(invocation, f -> {
- Assertions.assertTrue(f.isSucceed());
- Assertions.assertNull(f.getResult());
- });
- }
-
- @Test
- public void testHandleInError() throws Exception {
- Mockito.when(invocation.getMicroserviceName()).thenReturn("testHandleInError");
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName())
- .thenReturn("testHandleInError");
- FallbackPolicy policy = Mockito.mock(FallbackPolicy.class);
- Mockito.when(policy.name()).thenReturn("throwException");
- Mockito.when(policy.getFallbackResponse(Mockito.any(Invocation.class), Mockito.isNull()))
- .thenThrow(new RuntimeException());
- FallbackPolicyManager.addPolicy(policy);
- System.setProperty("servicecomb.fallbackpolicy.groupname.testHandleInError.policy", "throwException");
- Mockito.doAnswer((Answer<Void>) invocation -> {
- AsyncResponse asyncRsp = invocation.getArgument(0, AsyncResponse.class);
- asyncRsp.fail(InvocationType.CONSUMER, new Exception("testHandleInError"));
- return null;
- }).when(invocation).next(Mockito.any(AsyncResponse.class));
- bizkeeperHandler.handle(invocation, f -> Assertions.assertTrue(f.isFailed()));
- }
-
- @Test
- public void testHandlNextException() throws Exception {
- Mockito.when(invocation.getMicroserviceName()).thenReturn("testHandlNextException");
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName())
- .thenReturn("testHandlNextException");
- Mockito.doThrow(new Exception("testHandlNextException")).when(invocation).next(Mockito.any(AsyncResponse.class));
- bizkeeperHandler.handle(invocation, f -> Assertions.assertTrue(f.isFailed()));
- }
-
- @Test
- public void testHandleSuccess() throws Exception {
- Mockito.when(invocation.getMicroserviceName()).thenReturn("testHandleSuccess");
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName())
- .thenReturn("testHandleSuccess");
- Mockito.doAnswer((Answer<Void>) invocation -> {
- AsyncResponse asyncRsp = invocation.getArgument(0, AsyncResponse.class);
- asyncRsp.success("");
- return null;
- }).when(invocation).next(Mockito.any(AsyncResponse.class));
- bizkeeperHandler.handle(invocation, f -> Assertions.assertTrue(f.isSucceed()));
- }
-}
diff --git a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestBizkeeperRequestContext.java b/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestBizkeeperRequestContext.java
deleted file mode 100644
index f76125e51..000000000
--- a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestBizkeeperRequestContext.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-/**
- *
- *
- */
-public class TestBizkeeperRequestContext {
-
- @Test
- public void testInitializeContext() {
-
- BizkeeperRequestContext bizkeeperRequestContext = BizkeeperRequestContext.initializeContext();
- Assertions.assertNotNull(bizkeeperRequestContext);
- }
-
- @Test
- public void testShutdown() {
- BizkeeperRequestContext bizkeeperRequestContext = BizkeeperRequestContext.initializeContext();
- boolean validAssert;
-
- try {
- bizkeeperRequestContext.shutdown();
- validAssert = true;
- } catch (Exception e) {
- validAssert = false;
- }
-
- Assertions.assertTrue(validAssert);
- }
-}
diff --git a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestCommandKey.java b/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestCommandKey.java
deleted file mode 100644
index 899dc3861..000000000
--- a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestCommandKey.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.core.definition.OperationMeta;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-import com.netflix.hystrix.HystrixCommandGroupKey;
-import com.netflix.hystrix.HystrixCommandKey;
-
-/**
- *
- *
- */
-public class TestCommandKey {
-
- @Test
- public void testToHystrixCommandGroupKey() {
- Invocation invocation = Mockito.mock(Invocation.class);
-
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
- Assertions.assertNotNull(invocation);
- HystrixCommandGroupKey hystrixCommandGroupKey = CommandKey.toHystrixCommandGroupKey("groupname", invocation);
- Assertions.assertNotNull(hystrixCommandGroupKey);
- }
-
- @Test
- public void testToHystrixCommandKey() {
-
- Invocation invocation = Mockito.mock(Invocation.class);
-
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
- Assertions.assertNotNull(invocation);
- HystrixCommandKey hystrixCommandGroupKey = CommandKey.toHystrixCommandKey("groupname", invocation);
- Assertions.assertNotNull(hystrixCommandGroupKey);
- }
-}
diff --git a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestConfiguration.java b/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestConfiguration.java
deleted file mode 100644
index 41c15a7d3..000000000
--- a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestConfiguration.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.core.definition.OperationMeta;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-public class TestConfiguration {
- @Test
- public void testConfiguration() {
-
- Assertions.assertNotNull(Configuration.INSTANCE);
- Assertions.assertEquals("returnnull", Configuration.FALLBACKPOLICY_POLICY_RETURN);
- Assertions.assertEquals("throwexception", Configuration.FALLBACKPOLICY_POLICY_THROW);
-
- Configuration c = Configuration.INSTANCE;
- Invocation invocation = Mockito.mock(Invocation.class);
- String test2 = invocation.getMicroserviceName();
-
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceName()).thenReturn("testqualify");
-
- int res = c.getIsolationTimeoutInMilliseconds("groupname", test2, "testqualify");
- Assertions.assertEquals(30000, res);
- boolean b1 = c.getIsolationTimeoutEnabled("groupname", test2, "testqualify");
- Assertions.assertFalse(b1);
- int res1 = c.getIsolationMaxConcurrentRequests("groupname", test2, "testqualify");
- Assertions.assertEquals(1000, res1);
- boolean b2 = c.isCircuitBreakerEnabled("groupname", test2, "testqualify");
- Assertions.assertTrue(b2);
- String str = c.getFallbackPolicyPolicy("groupname", test2, "testqualify");
- // no need to give default value now
- Assertions.assertNull(str);
-
- Assertions.assertFalse(c.isCircuitBreakerForceOpen("groupname", test2, "testqualify"));
- Assertions.assertFalse(c.isCircuitBreakerForceClosed("groupname", test2, "testqualify"));
- Assertions.assertEquals(15000, c.getCircuitBreakerSleepWindowInMilliseconds("groupname", test2, "testqualify"));
- Assertions.assertEquals(20, c.getCircuitBreakerRequestVolumeThreshold("groupname", test2, "testqualify"));
- Assertions.assertEquals(50, c.getCircuitBreakerErrorThresholdPercentage("groupname", test2, "testqualify"));
- }
-}
diff --git a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestConsumerBizkeeperHandler.java b/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestConsumerBizkeeperHandler.java
deleted file mode 100644
index 63d3f2eff..000000000
--- a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestConsumerBizkeeperHandler.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.core.definition.OperationMeta;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-import com.netflix.hystrix.strategy.HystrixPlugins;
-
-/**
- *
- *
- */
-public class TestConsumerBizkeeperHandler {
-
- @Test
- public void testCreateBizkeeperCommand() {
- HystrixPlugins.reset();
- ConsumerBizkeeperHandler consumerBizkeeperHandler = new ConsumerBizkeeperHandler();
-
- Invocation invocation = Mockito.mock(Invocation.class);
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
-
- CommandKey.toHystrixCommandGroupKey("groupname", invocation);
- CommandKey.toHystrixCommandKey("groupname", invocation);
- BizkeeperCommand command = consumerBizkeeperHandler.createBizkeeperCommand(invocation);
- Assertions.assertNotNull(command);
- }
-}
diff --git a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestCustomCommandGroupKey.java b/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestCustomCommandGroupKey.java
deleted file mode 100644
index 6c854967b..000000000
--- a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestCustomCommandGroupKey.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-public class TestCustomCommandGroupKey {
- @Test
- public void testToHystrixCommandGroupKey() {
- Invocation invocation = Mockito.mock(Invocation.class);
- CustomizeCommandGroupKey customizeCommandGroupKey =
- (CustomizeCommandGroupKey) CustomizeCommandGroupKey.asKey("key", invocation);
- Assertions.assertEquals(invocation, customizeCommandGroupKey.getInstance());
- }
-
- @Test
- public void testOOM() {
- Invocation invocation1 = Mockito.mock(Invocation.class);
- Invocation invocation2 = Mockito.mock(Invocation.class);
- CustomizeCommandGroupKey customizeCommandGroupKey1 =
- (CustomizeCommandGroupKey) CustomizeCommandGroupKey.asKey("key", invocation1);
- CustomizeCommandGroupKey customizeCommandGroupKey2 =
- (CustomizeCommandGroupKey) CustomizeCommandGroupKey.asKey("key", invocation2);
- Assertions.assertEquals(customizeCommandGroupKey1, customizeCommandGroupKey2);
- }
-}
diff --git a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestFallbackPolicyManager.java b/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestFallbackPolicyManager.java
deleted file mode 100644
index d5bfc10e6..000000000
--- a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestFallbackPolicyManager.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import javax.ws.rs.core.Response.Status;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.core.definition.OperationMeta;
-import org.apache.servicecomb.core.exception.CseException;
-import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
-import org.apache.servicecomb.swagger.invocation.Response;
-import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-public class TestFallbackPolicyManager {
- @Test
- public void testFallbackPolicyManager() {
- OperationMeta operation = Mockito.mock(OperationMeta.class);
- Invocation invocation = Mockito.mock(Invocation.class);
-
- FallbackPolicyManager.addPolicy(new ReturnNullFallbackPolicy());
- FallbackPolicyManager.addPolicy(new ThrowExceptionFallbackPolicy());
- FallbackPolicyManager.addPolicy(new FromCacheFallbackPolicy());
- FallbackPolicyManager.addPolicy(new FallbackPolicy() {
- private static final String CUSTOM = "custom";
-
- @Override
- public String name() {
- return CUSTOM;
- }
-
- @Override
- public Response getFallbackResponse(Invocation invocation, Throwable error) {
- if (error instanceof InvocationException) {
- return Response.succResp("test");
- }
- if (error instanceof RuntimeException) {
- return Response.succResp("runtime");
- }
- return null;
- }
- });
-
- Mockito.when(operation.getMicroserviceQualifiedName()).thenReturn("testservice.schema.custom");
- Mockito.when(invocation.getMicroserviceName()).thenReturn("testservice");
- Mockito.when(invocation.getOperationMeta()).thenReturn(operation);
- ArchaiusUtils.setProperty("servicecomb.fallbackpolicy.Consumer.testservice.schema.custom.policy", "custom");
- Assertions.assertEquals("runtime",
- FallbackPolicyManager.getFallbackResponse("Consumer", new RuntimeException(), invocation)
- .getResult());
-
- Mockito.when(operation.getMicroserviceQualifiedName()).thenReturn("testservice.schema.returnnull");
- Mockito.when(invocation.getMicroserviceName()).thenReturn("testservice");
- Mockito.when(invocation.getOperationMeta()).thenReturn(operation);
- ArchaiusUtils.setProperty("servicecomb.fallbackpolicy.Consumer.testservice.schema.returnnull.policy", "returnnull");
- Assertions.assertEquals((String) null,
- FallbackPolicyManager.getFallbackResponse("Consumer", null, invocation).getResult());
-
- Mockito.when(operation.getMicroserviceQualifiedName()).thenReturn("testservice.schema.throwexception");
- Mockito.when(invocation.getMicroserviceName()).thenReturn("testservice");
- Mockito.when(invocation.getOperationMeta()).thenReturn(operation);
- ArchaiusUtils.setProperty("servicecomb.fallbackpolicy.Consumer.testservice.schema.throwexception.policy", "throwexception");
- Assertions.assertEquals(CseException.class,
- ((Exception) FallbackPolicyManager.getFallbackResponse("Consumer", null, invocation).getResult()).getCause()
- .getClass());
-
- Mockito.when(operation.getMicroserviceQualifiedName()).thenReturn("testservice.schema.fromcache");
- Mockito.when(invocation.getMicroserviceName()).thenReturn("testservice");
- Mockito.when(invocation.getOperationMeta()).thenReturn(operation);
- ArchaiusUtils.setProperty("servicecomb.fallbackpolicy.Consumer.testservice.schema.fromcache.policy", "fromcache");
- Mockito.when(invocation.getInvocationQualifiedName()).thenReturn("estservice.schema.fromcache");
-
- FallbackPolicyManager.record("Consumer", invocation, Response.succResp("mockedsuccess"), true);
- FallbackPolicyManager.record("Consumer", invocation, Response.succResp("mockedfailure"), false);
- Assertions.assertEquals("mockedsuccess",
- FallbackPolicyManager.getFallbackResponse("Consumer", null, invocation).getResult());
-
- Mockito.when(operation.getMicroserviceQualifiedName()).thenReturn("testservice.schema.unknown");
- Mockito.when(invocation.getMicroserviceName()).thenReturn("testservice");
- Mockito.when(invocation.getOperationMeta()).thenReturn(operation);
- ArchaiusUtils.setProperty("servicecomb.fallbackpolicy.Consumer.testservice.schema.unknown.policy", "unknown");
- Assertions.assertEquals(InvocationException.class,
- ((Exception) FallbackPolicyManager.getFallbackResponse("Consumer", new InvocationException(
- Status.TOO_MANY_REQUESTS, ""), invocation).getResult()).getClass());
-
- ArchaiusUtils.resetConfig();
- }
-}
diff --git a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestHystrixPropertiesStrategyExt.java b/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestHystrixPropertiesStrategyExt.java
deleted file mode 100644
index 036b4c12e..000000000
--- a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestHystrixPropertiesStrategyExt.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.core.definition.OperationMeta;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-import com.netflix.hystrix.HystrixCommandKey;
-import com.netflix.hystrix.HystrixCommandProperties;
-
-public class TestHystrixPropertiesStrategyExt {
-
- @Test
- public void testGetCommandPropertiesCacheKey() {
-
- Assertions.assertNotNull(HystrixPropertiesStrategyExt.getInstance());
-
- HystrixPropertiesStrategyExt hps = HystrixPropertiesStrategyExt.getInstance();
- HystrixCommandKey commandKey = Mockito.mock(HystrixCommandKey.class);
-
- Invocation invocation = Mockito.mock(Invocation.class);
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceName()).thenReturn("testqualify");
-
- HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter()
- .withRequestCacheEnabled(true)
- .withRequestLogEnabled(false)
- .withFallbackIsolationSemaphoreMaxConcurrentRequests(
- Configuration.INSTANCE.getFallbackMaxConcurrentRequests("groupname",
- "testing",
- invocation.getOperationMeta().getMicroserviceQualifiedName()));
-
- String str1 = hps.getCommandPropertiesCacheKey(commandKey, setter);
- Assertions.assertNull(str1);
- }
-
- @Test
- public void testgetCommandProperties() {
- HystrixCommandKey commandKey = Mockito.mock(HystrixCommandKey.class);
- Mockito.when(commandKey.name())
- .thenReturn("provider.HystrixPropertiesStrategyExtTest.testgetCommandProperties");
- HystrixCommandProperties commandPro = HystrixPropertiesStrategyExt.getInstance()
- .getCommandProperties(commandKey, HystrixCommandProperties.Setter());
- Assertions.assertTrue(commandPro.circuitBreakerEnabled().get());
- Assertions.assertEquals(Integer.valueOf(50), commandPro.circuitBreakerErrorThresholdPercentage().get());
- Assertions.assertFalse(commandPro.circuitBreakerForceClosed().get());
- Assertions.assertFalse(commandPro.circuitBreakerForceOpen().get());
- Assertions.assertEquals(Integer.valueOf(20), commandPro.circuitBreakerRequestVolumeThreshold().get());
- Assertions.assertEquals(Integer.valueOf(15000), commandPro.circuitBreakerSleepWindowInMilliseconds().get());
- Assertions.assertEquals(Integer.valueOf(1000), commandPro.executionIsolationSemaphoreMaxConcurrentRequests().get());
- Assertions.assertTrue(commandPro.executionIsolationThreadInterruptOnTimeout().get());
- Assertions.assertNull(commandPro.executionIsolationThreadPoolKeyOverride().get());
- Assertions.assertEquals(Integer.valueOf(30000), commandPro.executionTimeoutInMilliseconds().get());
- Assertions.assertFalse(commandPro.executionTimeoutEnabled().get());
- Assertions.assertEquals(Integer.valueOf(10), commandPro.fallbackIsolationSemaphoreMaxConcurrentRequests().get());
- Assertions.assertTrue(commandPro.fallbackEnabled().get());
- Assertions.assertEquals(Integer.valueOf(100), commandPro.metricsRollingPercentileBucketSize().get());
- Assertions.assertFalse(commandPro.metricsRollingPercentileEnabled().get());
- }
-}
diff --git a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestProviderBizkeeperHandler.java b/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestProviderBizkeeperHandler.java
deleted file mode 100644
index de4b26ad9..000000000
--- a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/TestProviderBizkeeperHandler.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper;
-
-import org.apache.servicecomb.core.Invocation;
-import org.apache.servicecomb.core.definition.OperationMeta;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-import com.netflix.hystrix.strategy.HystrixPlugins;
-
-/**
- *
- *
- */
-public class TestProviderBizkeeperHandler {
-
- @Test
- public void testCreateBizkeeperCommand() {
- HystrixPlugins.reset();
- ProviderBizkeeperHanlder providerBizkeeperHanlder = new ProviderBizkeeperHanlder();
-
- Invocation invocation = Mockito.mock(Invocation.class);
- Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
- Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
-
- CommandKey.toHystrixCommandGroupKey("groupname", invocation);
- CommandKey.toHystrixCommandKey("groupname", invocation);
- BizkeeperCommand command = providerBizkeeperHanlder.createBizkeeperCommand(invocation);
- Assertions.assertNotNull(command);
- }
-}
diff --git a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/event/TestCircutBreakerEventNotifier.java b/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/event/TestCircutBreakerEventNotifier.java
deleted file mode 100644
index 1bb46292a..000000000
--- a/handlers/handler-bizkeeper/src/test/java/org/apache/servicecomb/bizkeeper/event/TestCircutBreakerEventNotifier.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.servicecomb.bizkeeper.event;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.servicecomb.foundation.common.event.AlarmEvent;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.MockedStatic;
-import org.mockito.Mockito;
-
-import com.google.common.eventbus.Subscribe;
-import com.netflix.hystrix.HystrixCommandKey;
-import com.netflix.hystrix.HystrixCommandMetrics;
-import com.netflix.hystrix.HystrixEventType;
-
-public class TestCircutBreakerEventNotifier {
- private List<AlarmEvent> taskList = null;
-
- CircutBreakerEventNotifier circutBreakerEventNotifier;
-
- HystrixCommandKey commandKey = null;
-
- Object receiveEvent = null;
-
- public static class EventSubscriber {
- final List<AlarmEvent> taskList;
-
- public EventSubscriber(List<AlarmEvent> taskList) {
- this.taskList = taskList;
- }
-
- @Subscribe
- public void onEvent(AlarmEvent circutBreakerEvent) {
- taskList.add(circutBreakerEvent);
- }
- }
-
- @BeforeEach
- public void setUp() throws Exception {
- taskList = new ArrayList<>();
- circutBreakerEventNotifier = new CircutBreakerEventNotifier();
- commandKey = Mockito.mock(HystrixCommandKey.class);
- receiveEvent = new EventSubscriber(taskList);
- circutBreakerEventNotifier.eventBus.register(receiveEvent);
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- circutBreakerEventNotifier.eventBus.unregister(receiveEvent);
- }
-
- @Test
- public void testMarkEvent() {
- Mockito.when(commandKey.name()).thenReturn("Consumer.springmvc.springmvcHello.sayHi");
- try (MockedStatic<HystrixCommandMetrics> mockedStatic = Mockito.mockStatic(HystrixCommandMetrics.class)) {
- mockedStatic.when(() -> HystrixCommandMetrics.getInstance(commandKey)).thenReturn(null);
- circutBreakerEventNotifier.markEvent(HystrixEventType.SHORT_CIRCUITED, commandKey);
- Assertions.assertEquals(1, taskList.size());
- circutBreakerEventNotifier.markEvent(HystrixEventType.SUCCESS, commandKey);
- Assertions.assertEquals(2, taskList.size());
- }
- }
-}
diff --git a/handlers/pom.xml b/handlers/pom.xml
index d0fa5492f..b12db3f27 100644
--- a/handlers/pom.xml
+++ b/handlers/pom.xml
@@ -33,7 +33,6 @@
<modules>
<module>handler-tracing-zipkin</module>
- <module>handler-bizkeeper</module>
<module>handler-flowcontrol-qps</module>
<module>handler-loadbalance</module>
<module>handler-fault-injection</module>
diff --git a/huawei-cloud/dashboard/pom.xml b/huawei-cloud/dashboard/pom.xml
index f877b98bd..e580ae538 100644
--- a/huawei-cloud/dashboard/pom.xml
+++ b/huawei-cloud/dashboard/pom.xml
@@ -49,11 +49,6 @@
</dependency>
<!-- optional dependencies -->
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handler-bizkeeper</artifactId>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>metrics-core</artifactId>
diff --git a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/HealthMonitorDataProvider.java b/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/HealthMonitorDataProvider.java
deleted file mode 100644
index 1a00cc5c1..000000000
--- a/huawei-cloud/dashboard/src/main/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/HealthMonitorDataProvider.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.servicecomb.huaweicloud.dashboard.monitor;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.Collection;
-
-import org.apache.servicecomb.dashboard.client.model.InterfaceInfo;
-import org.apache.servicecomb.dashboard.client.model.MonitorData;
-import org.apache.servicecomb.huaweicloud.dashboard.monitor.model.MonitorDataProvider;
-
-import com.netflix.config.DynamicPropertyFactory;
-import com.netflix.hystrix.HystrixCircuitBreaker;
-import com.netflix.hystrix.HystrixCommandMetrics;
-import com.netflix.hystrix.HystrixEventType;
-
-/**
- * This provider depends on bizkeeper. Because Bizkeeper depends on Hystrix
- * and it is not in maintainence, will keep it here for compatible reason.
- */
-public class HealthMonitorDataProvider implements MonitorDataProvider {
- @Override
- public boolean enabled() {
- return DynamicPropertyFactory.getInstance()
- .getBooleanProperty("servicecomb.monitor.provider.bizkeeper.enabled", false)
- .get();
- }
-
- @Override
- public void extractInterfaceInfo(MonitorData monitorData) {
- Collection<HystrixCommandMetrics> instances = HystrixCommandMetrics.getInstances();
- if (instances.isEmpty()) {
- return;
- }
- for (HystrixCommandMetrics instance : instances) {
- appendInterfaceInfo(monitorData, instance);
- }
- }
-
- private void appendInterfaceInfo(MonitorData monitorData, HystrixCommandMetrics metrics) {
- InterfaceInfo interfaceInfo = new InterfaceInfo();
- int windowTime =
- metrics.getProperties().metricsRollingStatisticalWindowInMilliseconds().get() / MonitorData.CONVERSION;
- long successCount = metrics.getRollingCount(HystrixEventType.SUCCESS);
- long failureCount = metrics.getRollingCount(HystrixEventType.FAILURE);
- long semRejectCount = metrics.getRollingCount(HystrixEventType.SEMAPHORE_REJECTED);
- long threadRejectCount = metrics.getRollingCount(HystrixEventType.THREAD_POOL_REJECTED);
- long timeoutCount = metrics.getRollingCount(HystrixEventType.TIMEOUT);
- long shortCircuitedCount = metrics.getRollingCount(HystrixEventType.SHORT_CIRCUITED);
- long rollingErrorTotal = failureCount + semRejectCount + threadRejectCount + timeoutCount;
- long rollingTotal = successCount + rollingErrorTotal;
-
- if (rollingTotal == 0) {
- interfaceInfo.setRate(MonitorData.DEFAULT_SUCCESS_RATE);
- interfaceInfo.setFailureRate(0d);
- } else {
- double failurePercentage = (double) rollingErrorTotal / rollingTotal;
- interfaceInfo.setRate(MonitorData.DEFAULT_SUCCESS_RATE - failurePercentage);
- interfaceInfo.setFailureRate(failurePercentage);
- }
-
- int latency = metrics.getTotalTimeMean();
- int latency995 = metrics.getTotalTimePercentile(MonitorData.PERCENTAGE_995);
- int latency99 = metrics.getTotalTimePercentile(MonitorData.PERCENTAGE_99);
- int latency90 = metrics.getTotalTimePercentile(MonitorData.PERCENTAGE_90);
- int latency75 = metrics.getTotalTimePercentile(MonitorData.PERCENTAGE_75);
- int latency50 = metrics.getTotalTimePercentile(MonitorData.PERCENTAGE_50);
- int latency25 = metrics.getTotalTimePercentile(MonitorData.PERCENTAGE_25);
- int latency5 = metrics.getTotalTimePercentile(MonitorData.PERCENTAGE_5);
-
- interfaceInfo.setName(metrics.getCommandKey().name());
- interfaceInfo.setCircuitBreakerOpen(isOpen(metrics));
- interfaceInfo.setShortCircuited(shortCircuitedCount);
- interfaceInfo.setFailureRate(failureCount);
- interfaceInfo.setSemaphoreRejected(semRejectCount);
- interfaceInfo.setThreadPoolRejected(threadRejectCount);
- interfaceInfo.setCountTimeout(timeoutCount);
- interfaceInfo.setDesc(metrics.getCommandKey().name());
- interfaceInfo.setLatency(latency);
- interfaceInfo.setL995(latency995);
- interfaceInfo.setL99(latency99);
- interfaceInfo.setL90(latency90);
- interfaceInfo.setL75(latency75);
- interfaceInfo.setL50(latency50);
- interfaceInfo.setL25(latency25);
- interfaceInfo.setL5(latency5);
- interfaceInfo.setTotal(rollingTotal);
- double qpsVal = ((double) rollingTotal) / windowTime;
- BigDecimal b = new BigDecimal(qpsVal);
- BigDecimal qps = b.setScale(MonitorData.SCALE_VAL, RoundingMode.HALF_DOWN);
- interfaceInfo.setQps(qps.doubleValue());
- monitorData.addInterfaceInfo(interfaceInfo);
- }
-
- private boolean isOpen(HystrixCommandMetrics metrics) {
- if (metrics.getProperties().circuitBreakerForceOpen().get()) {
- return true;
- }
- if (metrics.getProperties().circuitBreakerForceClosed().get()) {
- return false;
- }
- HystrixCircuitBreaker circuitBreaker = HystrixCircuitBreaker.Factory.getInstance(metrics.getCommandKey());
- return circuitBreaker != null && circuitBreaker.isOpen();
- }
-}
diff --git a/huawei-cloud/dashboard/src/test/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MetricsMonitorDataProviderTest.java b/huawei-cloud/dashboard/src/test/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MetricsMonitorDataProviderTest.java
index 3758bd4bb..c5411febd 100644
--- a/huawei-cloud/dashboard/src/test/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MetricsMonitorDataProviderTest.java
+++ b/huawei-cloud/dashboard/src/test/java/org/apache/servicecomb/huaweicloud/dashboard/monitor/MetricsMonitorDataProviderTest.java
@@ -16,15 +16,6 @@
*/
package org.apache.servicecomb.huaweicloud.dashboard.monitor;
-import org.apache.commons.configuration.Configuration;
-import org.apache.servicecomb.config.ConfigUtil;
-import org.apache.servicecomb.huaweicloud.dashboard.monitor.model.MonitorDataProvider;
-import org.apache.servicecomb.registry.api.registry.Microservice;
-import org.apache.servicecomb.serviceregistry.RegistryUtils;
-import org.apache.servicecomb.serviceregistry.ServiceRegistry;
-import org.apache.servicecomb.serviceregistry.config.ServiceRegistryConfig;
-import org.apache.servicecomb.serviceregistry.registry.ServiceRegistryFactory;
-import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -36,15 +27,4 @@ public class MetricsMonitorDataProviderTest {
Assertions.assertFalse("2002".matches(MetricsMonitorDataProvider.CODE_SUCCESS));
Assertions.assertFalse("400".matches(MetricsMonitorDataProvider.CODE_SUCCESS));
}
-
- @Test
- public void testEnvironment() {
- Configuration configuration = ConfigUtil.createLocalConfig();
- ServiceRegistry serviceRegistry = ServiceRegistryFactory.create(ServiceRegistryConfig.INSTANCE, configuration);
- Microservice microservice = serviceRegistry.getMicroservice();
- MonitorDataProvider monitorDataProvider = new HealthMonitorDataProvider();
- RegistryUtils.setServiceRegistry(serviceRegistry);
- Assert.assertEquals(monitorDataProvider.getData().getEnvironment(), microservice.getEnvironment());
- Assert.assertEquals("development", monitorDataProvider.getData().getEnvironment());
- }
}
diff --git a/solutions/solution-basic/pom.xml b/solutions/solution-basic/pom.xml
index 14b177bbb..c381eccb3 100644
--- a/solutions/solution-basic/pom.xml
+++ b/solutions/solution-basic/pom.xml
@@ -59,10 +59,6 @@
</dependency>
<!-- handlers -->
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handler-bizkeeper</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>handler-fault-injection</artifactId>
diff --git a/spring-boot/spring-boot-starters/java-chassis-spring-boot-starter/pom.xml b/spring-boot/spring-boot-starters/java-chassis-spring-boot-starter/pom.xml
index fc14ca12c..8248fd53e 100644
--- a/spring-boot/spring-boot-starters/java-chassis-spring-boot-starter/pom.xml
+++ b/spring-boot/spring-boot-starters/java-chassis-spring-boot-starter/pom.xml
@@ -51,10 +51,6 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>provider-pojo</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handler-bizkeeper</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>handler-loadbalance</artifactId>