You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/09/17 06:55:47 UTC

[GitHub] [servicecomb-java-chassis] develpoerX opened a new pull request #2584: [WIP] SCB-2330 add injectFault into governance

develpoerX opened a new pull request #2584:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2584


   Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `mvn clean install -Pit` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] codecov-commenter commented on pull request #2584: [WIP] SCB-2330 add injectFault into governance

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #2584:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2584#issuecomment-980487502


   # [Codecov](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2584](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (651d984) into [master](https://codecov.io/gh/apache/servicecomb-java-chassis/commit/8207a76ecb0620f989173ce5c5a776aaaea0af4d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8207a76) will **decrease** coverage by `0.07%`.
   > The diff coverage is `33.78%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584/graphs/tree.svg?width=650&height=150&src=pr&token=KXfDcr9rX2&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #2584      +/-   ##
   ============================================
   - Coverage     77.68%   77.60%   -0.08%     
     Complexity     1429     1429              
   ============================================
     Files          1598     1605       +7     
     Lines         42740    42814      +74     
     Branches       3606     3608       +2     
   ============================================
   + Hits          33202    33227      +25     
   - Misses         8027     8074      +47     
   - Partials       1511     1513       +2     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...he/servicecomb/injection/FaultInjectionConfig.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvaW5qZWN0aW9uL0ZhdWx0SW5qZWN0aW9uQ29uZmlnLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...che/servicecomb/injection/FaultInjectionConst.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvaW5qZWN0aW9uL0ZhdWx0SW5qZWN0aW9uQ29uc3QuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...ache/servicecomb/injection/FaultInjectionUtil.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvaW5qZWN0aW9uL0ZhdWx0SW5qZWN0aW9uVXRpbC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...a/org/apache/servicecomb/injection/FaultParam.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvaW5qZWN0aW9uL0ZhdWx0UGFyYW0uamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...comb/governance/handler/FaultInjectionHandler.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvZ292ZXJuYW5jZS9oYW5kbGVyL0ZhdWx0SW5qZWN0aW9uSGFuZGxlci5qYXZh) | `15.38% <15.38%> (ø)` | |
   | [...cecomb/governance/policy/FaultInjectionPolicy.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvZ292ZXJuYW5jZS9wb2xpY3kvRmF1bHRJbmplY3Rpb25Qb2xpY3kuamF2YQ==) | `83.33% <83.33%> (ø)` | |
   | [...overnance/properties/FaultInjectionProperties.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvZ292ZXJuYW5jZS9wcm9wZXJ0aWVzL0ZhdWx0SW5qZWN0aW9uUHJvcGVydGllcy5qYXZh) | `100.00% <100.00%> (ø)` | |
   | [...he/servicecomb/foundation/common/net/NetUtils.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Zm91bmRhdGlvbnMvZm91bmRhdGlvbi1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NlcnZpY2Vjb21iL2ZvdW5kYXRpb24vY29tbW9uL25ldC9OZXRVdGlscy5qYXZh) | `62.99% <0.00%> (-1.58%)` | :arrow_down: |
   | [...egistry/client/http/ServiceRegistryClientImpl.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2VydmljZS1yZWdpc3RyeS9yZWdpc3RyeS1zZXJ2aWNlLWNlbnRlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvc2VydmljZXJlZ2lzdHJ5L2NsaWVudC9odHRwL1NlcnZpY2VSZWdpc3RyeUNsaWVudEltcGwuamF2YQ==) | `71.26% <0.00%> (+0.38%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [8207a76...651d984](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/2584?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #2584: [WIP] SCB-2330 add injectFault into governance

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #2584:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2584#discussion_r714503971



##########
File path: governance/src/main/java/org/apache/servicecomb/governance/policy/FaultInjectionPolicy.java
##########
@@ -0,0 +1,68 @@
+package org.apache.servicecomb.governance.policy;
+
+import java.time.Duration;
+import java.util.List;
+
+public class FaultInjectionPolicy extends AbstractPolicy {
+  public static final Duration DEFAULT_TIMEOUT_DURATION = Duration.ofMillis(0);
+
+  public static final Duration DEFAULT_LIMIT_REFRESH_PERIOD = Duration.ofMillis(1000);

Review comment:
       unused code




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #2584: [WIP] SCB-2330 add injectFault into governance

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #2584:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2584#discussion_r714503670



##########
File path: governance/src/main/java/org/apache/servicecomb/governance/handler/FaultInjectionHandler.java
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.governance.handler;
+
+import java.time.Duration;
+
+import org.apache.servicecomb.governance.marker.GovernanceRequest;
+import org.apache.servicecomb.governance.policy.FaultInjectionPolicy;
+import org.apache.servicecomb.governance.properties.FaultInjectionProperties;
+import org.apache.servicecomb.injection.FaultInjectionConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class FaultInjectionHandler extends AbstractGovernanceHandler<FaultInjectionPolicy, FaultInjectionPolicy> {
+  private static final Logger LOGGER = LoggerFactory.getLogger(RateLimitingHandler.class);
+
+  @Autowired
+  private FaultInjectionProperties faultInjectionProperties;
+
+  @Override
+  protected String createKey(FaultInjectionPolicy policy) {
+    return "servicecomb.faultInjection." + policy.getName();
+  }
+
+  @Override
+  public FaultInjectionPolicy matchPolicy(GovernanceRequest governanceRequest) {
+    return matchersManager.match(governanceRequest, faultInjectionProperties.getParsedEntity());
+  }
+
+  @Override
+  protected FaultInjectionPolicy createProcessor(FaultInjectionPolicy policy) {
+    return policy;
+  }
+
+
+  private FaultInjectionConfig getFaultInjection(FaultInjectionPolicy policy) {
+    LOGGER.info("applying new policy: {}", policy.toString());
+
+    FaultInjectionConfig config;
+    config = FaultInjectionConfig.custom()
+        .setType(policy.getType())
+        .setDelayTime(Duration.parse(policy.getDelayTime()))
+        .setPercentage(policy.getPercentage())
+        .setResponseStatus(policy.getErrorCode())
+        .build();
+    return config;
+  }

Review comment:
       unused code




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #2584: [WIP] SCB-2330 add injectFault into governance

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #2584:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2584#discussion_r714503073



##########
File path: governance/src/main/java/org/apache/servicecomb/governance/handler/FaultInjectionHandler.java
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.governance.handler;
+
+import java.time.Duration;
+
+import org.apache.servicecomb.governance.marker.GovernanceRequest;
+import org.apache.servicecomb.governance.policy.FaultInjectionPolicy;
+import org.apache.servicecomb.governance.properties.FaultInjectionProperties;
+import org.apache.servicecomb.injection.FaultInjectionConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class FaultInjectionHandler extends AbstractGovernanceHandler<FaultInjectionPolicy, FaultInjectionPolicy> {
+  private static final Logger LOGGER = LoggerFactory.getLogger(RateLimitingHandler.class);

Review comment:
       should be FaultInjectionHandler




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #2584: [WIP] SCB-2330 add injectFault into governance

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #2584:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2584#discussion_r714504897



##########
File path: governance/src/main/java/org/apache/servicecomb/injection/AbortFault.java
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.injection;
+
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.governance.policy.FaultInjectionPolicy;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+import org.apache.servicecomb.swagger.invocation.exception.CommonExceptionData;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AbortFault implements Fault {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(AbortFault.class);
+
+  public static final String ABORTED_ERROR_MSG = "aborted by fault inject";
+
+  @Override
+  public void injectFault(Invocation invocation, FaultParam param, FaultInjectionPolicy policy,
+      AsyncResponse asyncResponse) {
+    if (!shouldAbort(invocation, param, policy)) {
+      asyncResponse.success(SUCCESS_RESPONSE);

Review comment:
       invocation.next(aysncResponse)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #2584: [WIP] SCB-2330 add injectFault into governance

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #2584:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2584#discussion_r714506465



##########
File path: handlers/handler-governance/src/main/java/org/apache/servicecomb/handler/governance/FaultsInjectionHandler.java
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.handler.governance;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.servicecomb.core.Handler;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
+import org.apache.servicecomb.governance.handler.FaultInjectionHandler;
+import org.apache.servicecomb.governance.marker.GovernanceRequest;
+import org.apache.servicecomb.governance.policy.FaultInjectionPolicy;
+import org.apache.servicecomb.injection.Fault;
+import org.apache.servicecomb.injection.FaultInjectionUtil;
+import org.apache.servicecomb.injection.FaultParam;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+
+import io.vertx.core.Context;
+import io.vertx.core.Vertx;
+
+/**
+ * Fault injection handler which injects the delay/abort for requests based on
+ * the percentage configured in service file.
+ *
+ */
+
+public class FaultsInjectionHandler implements Handler {

Review comment:
       move this code to handler-governance module. and maybe no need to create a new handler. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #2584: [WIP] SCB-2330 add injectFault into governance

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #2584:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2584#discussion_r714502711



##########
File path: governance/pom.xml
##########
@@ -81,5 +81,9 @@
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>foundation-common</artifactId>
     </dependency>
+    <dependency>

Review comment:
       Do not include this dependency. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] develpoerX commented on a change in pull request #2584: [WIP] SCB-2330 add injectFault into governance

Posted by GitBox <gi...@apache.org>.
develpoerX commented on a change in pull request #2584:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2584#discussion_r757993892



##########
File path: handlers/handler-governance/src/main/java/org/apache/servicecomb/handler/governance/FaultsInjectionHandler.java
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.handler.governance;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.servicecomb.core.Handler;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
+import org.apache.servicecomb.governance.handler.FaultInjectionHandler;
+import org.apache.servicecomb.governance.marker.GovernanceRequest;
+import org.apache.servicecomb.governance.policy.FaultInjectionPolicy;
+import org.apache.servicecomb.injection.Fault;
+import org.apache.servicecomb.injection.FaultInjectionUtil;
+import org.apache.servicecomb.injection.FaultParam;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+
+import io.vertx.core.Context;
+import io.vertx.core.Vertx;
+
+/**
+ * Fault injection handler which injects the delay/abort for requests based on
+ * the percentage configured in service file.
+ *
+ */
+
+public class FaultsInjectionHandler implements Handler {

Review comment:
       done. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #2584: [WIP] SCB-2330 add injectFault into governance

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #2584:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2584#discussion_r714504897



##########
File path: governance/src/main/java/org/apache/servicecomb/injection/AbortFault.java
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.injection;
+
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.governance.policy.FaultInjectionPolicy;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+import org.apache.servicecomb.swagger.invocation.exception.CommonExceptionData;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AbortFault implements Fault {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(AbortFault.class);
+
+  public static final String ABORTED_ERROR_MSG = "aborted by fault inject";
+
+  @Override
+  public void injectFault(Invocation invocation, FaultParam param, FaultInjectionPolicy policy,
+      AsyncResponse asyncResponse) {
+    if (!shouldAbort(invocation, param, policy)) {
+      asyncResponse.success(SUCCESS_RESPONSE);

Review comment:
       invocation.next(aysncResponse) and move this code to handler-governance module




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #2584: [WIP] SCB-2330 add injectFault into governance

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #2584:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2584#discussion_r714506465



##########
File path: handlers/handler-governance/src/main/java/org/apache/servicecomb/handler/governance/FaultsInjectionHandler.java
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.handler.governance;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.servicecomb.core.Handler;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
+import org.apache.servicecomb.governance.handler.FaultInjectionHandler;
+import org.apache.servicecomb.governance.marker.GovernanceRequest;
+import org.apache.servicecomb.governance.policy.FaultInjectionPolicy;
+import org.apache.servicecomb.injection.Fault;
+import org.apache.servicecomb.injection.FaultInjectionUtil;
+import org.apache.servicecomb.injection.FaultParam;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+
+import io.vertx.core.Context;
+import io.vertx.core.Vertx;
+
+/**
+ * Fault injection handler which injects the delay/abort for requests based on
+ * the percentage configured in service file.
+ *
+ */
+
+public class FaultsInjectionHandler implements Handler {

Review comment:
       move this code to handler-governance module




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #2584: [WIP] SCB-2330 add injectFault into governance

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #2584:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2584#discussion_r714506095



##########
File path: handlers/handler-governance/src/main/java/org/apache/servicecomb/handler/governance/FaultExecutor.java
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.handler.governance;
+
+import java.util.List;
+
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.governance.marker.GovernanceRequest;
+import org.apache.servicecomb.governance.policy.FaultInjectionPolicy;
+import org.apache.servicecomb.injection.AbortFault;
+import org.apache.servicecomb.injection.DelayFault;
+import org.apache.servicecomb.injection.Fault;
+import org.apache.servicecomb.injection.FaultParam;
+import org.apache.servicecomb.swagger.invocation.AsyncResponse;
+import org.apache.servicecomb.swagger.invocation.Response;
+import org.springframework.beans.factory.annotation.Autowired;
+
+
+/**
+ * Implements the fault feature execution one after other.
+ */
+public class FaultExecutor {
+  private List<Fault> faultInjectList;
+
+  private int handlerIndex = 0;
+
+  private Invocation invocation;
+
+  private FaultParam param;
+
+  private FaultInjectionPolicy policy;
+
+  private Fault fault;
+
+  public FaultExecutor(List<Fault> faultInjectList, Invocation invocation, FaultParam param, FaultInjectionPolicy policy) {
+    this.faultInjectList = faultInjectList;
+    this.invocation = invocation;
+    this.param = param;
+    this.policy =policy;
+  }
+
+  public void execute(AsyncResponse asyncResponse) {
+    if(policy.getType().equals("delay")) {
+      fault = new DelayFault();
+    } else {
+      fault = new AbortFault();
+    }

Review comment:
       initialize fault type when configuration changed. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org