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 2022/08/05 10:34:08 UTC
[GitHub] [servicecomb-java-chassis] lbc97 opened a new pull request, #3267: add loadbalance governance
lbc97 opened a new pull request, #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267
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] liubao68 commented on a diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939499357
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/LoadBalance.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * 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.loadbanlance;
+
+import io.vavr.CheckedFunction0;
+
+public interface LoadBalance {
+
+ static String decorateCheckedSupplier(LoadBalance loadBalance) {
+ return loadBalance.choose();
+ }
+
+ public String choose();
+
+ public String choose(String type);
+
+ int getOrder();
+
+ String getName();
Review Comment:
only need one method `getRule`
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939499357
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/LoadBalance.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * 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.loadbanlance;
+
+import io.vavr.CheckedFunction0;
+
+public interface LoadBalance {
+
+ static String decorateCheckedSupplier(LoadBalance loadBalance) {
+ return loadBalance.choose();
+ }
+
+ public String choose();
+
+ public String choose(String type);
+
+ int getOrder();
+
+ String getName();
Review Comment:
only need one method `getRule` which return rule in LoadBalancePolicy
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939532310
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/LoadBalanceImpl.java:
##########
@@ -0,0 +1,28 @@
+package org.apache.servicecomb.loadbanlance;
+
+public class LoadBalanceImpl implements LoadBalance {
+ private String rule;
Review Comment:
should be final
--
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 merged pull request #3267: [SCB-2665]Add the load balance governance
Posted by GitBox <gi...@apache.org>.
liubao68 merged PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939499763
##########
governance/src/main/java/org/apache/servicecomb/governance/handler/LoadBalanceHandler.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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 org.apache.servicecomb.governance.marker.GovernanceRequest;
+import org.apache.servicecomb.governance.policy.LoadBalancerPolicy;
+import org.apache.servicecomb.governance.properties.LoadBalanceProperties;
+import org.apache.servicecomb.loadbanlance.LoadBalance;
+import org.apache.servicecomb.loadbanlance.LoadBalanceConst;
+import org.apache.servicecomb.loadbanlance.LoadBalanceUtil;
+
+public class LoadBalanceHandler extends AbstractGovernanceHandler<LoadBalance, LoadBalancerPolicy> {
+
+ private final LoadBalanceProperties loadBalanceProperties;
+
+ public LoadBalanceHandler(LoadBalanceProperties loadBalanceProperties) {
+ this.loadBalanceProperties = loadBalanceProperties;
+ }
+
+ @Override
+ protected String createKey(GovernanceRequest governanceRequest, LoadBalancerPolicy policy) {
+ return LoadBalanceProperties.MATCH_LOADBANLANCER_KEY + "." + policy.getName();
+ }
+
+ @Override
+ public LoadBalancerPolicy matchPolicy(GovernanceRequest governanceRequest) {
+ return matchersManager.match(governanceRequest, loadBalanceProperties.getParsedEntity());
+ }
+
+ @Override
+ protected LoadBalance createProcessor(String key, GovernanceRequest governanceRequest, LoadBalancerPolicy policy) {
+ return LoadBalanceUtil.getLoadBalance(key, policy);
Review Comment:
return new LoadBalanceImpl()
```
class LoadBalanceImpl implements LoadBalance {
@Override
public String getRule() {
return policy.getRule();
}
}
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939499449
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/LoadBalanceDecorators.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.loadbanlance;
+
+import io.vavr.CheckedFunction0;
+
+public interface LoadBalanceDecorators {
+ static <T> LoadBalanceDecorateCheckedSupplier<T> ofCheckedSupplier(CheckedFunction0<T> supplier) {
+ return new LoadBalanceDecorateCheckedSupplier<>(supplier);
+ }
+
+ class LoadBalanceDecorateCheckedSupplier<T> {
+
+ private CheckedFunction0<T> supplier;
+
+ protected LoadBalanceDecorateCheckedSupplier(CheckedFunction0<T> supplier) {
+ this.supplier = supplier;
+ }
+
+ public String withFaultInjection(LoadBalance loadBalance) {
+ return LoadBalance.decorateCheckedSupplier(loadBalance);
+ }
+
+ public T get() throws Throwable {
Review Comment:
do not need this class
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/LoadBalanceUtil.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.loadbanlance;
+
+import org.apache.servicecomb.governance.policy.LoadBalancerPolicy;
+
+public class LoadBalanceUtil {
+
+ public static LoadBalance getLoadBalance(String key, LoadBalancerPolicy policy) {
+ LoadBalance loadBalance = null;
+ if (LoadBalanceConst.TYPE_RANDOM.equals(policy.getLoadrule())) {
+ loadBalance = new RandomBalancer(LoadBalanceConst.TYPE_RANDOM);
+ } else if (LoadBalanceConst.TYPE_ROUNDROBIN.equals(policy.getLoadrule())) {
+ loadBalance = new RoundRobinBalancer(LoadBalanceConst.TYPE_ROUNDROBIN);
+ }
+ return loadBalance;
+ }
+}
Review Comment:
do not need this
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939499203
##########
governance/src/test/resources/application.yaml:
##########
@@ -16,6 +16,9 @@
## ---------------------------------------------------------------------------
servicecomb:
+ loadbalance:
+ rule: |
+ loadrule: Random
Review Comment:
```
servicecomb:
loadbalance:
XXXXXXMatch: |
rule: Random
```
Use this definition and should define `matchGroup` for `XXXXXXMatch`
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939532340
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/LoadBalanceImpl.java:
##########
@@ -0,0 +1,28 @@
+package org.apache.servicecomb.loadbanlance;
+
+public class LoadBalanceImpl implements LoadBalance {
+ private String rule;
+
+ public String getRule() {
+ return rule;
+ }
+
+ public void setRule(String rule) {
+ this.rule = rule;
+ }
Review Comment:
put methods definition after constructor
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939498891
##########
governance/src/test/java/org/apache/servicecomb/governance/LoadBalancerTest.java:
##########
@@ -0,0 +1,36 @@
+package org.apache.servicecomb.governance;
+
+import org.apache.servicecomb.governance.handler.LoadBalanceHandler;
+import org.apache.servicecomb.governance.marker.GovernanceRequest;
+import org.apache.servicecomb.loadbanlance.LoadBalance;
+import org.apache.servicecomb.loadbanlance.LoadBalanceDecorators;
+import org.apache.servicecomb.loadbanlance.LoadBalanceDecorators.LoadBalanceDecorateCheckedSupplier;
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+
+@SpringBootTest
+@ContextConfiguration(classes = {GovernanceConfiguration.class, MockConfiguration.class})
+public class LoadBalancerTest {
+ private LoadBalanceHandler loadBalanceHandler;
+
+ @Autowired
+ public void setLoadBalanceHandler(LoadBalanceHandler loadBalanceHandler) {
+ this.loadBalanceHandler = loadBalanceHandler;
+ }
+
+ public LoadBalancerTest() {
+
+ }
+ @Test
+ public void test_loadbalance_random() {
+ LoadBalanceDecorateCheckedSupplier<Object> ds = LoadBalanceDecorators.ofCheckedSupplier(()->"test");
+ GovernanceRequest request = new GovernanceRequest();
+ request.setUri("/loadrandom");
+ request.setServiceName("RandomTest");
+ LoadBalance loadBalance = loadBalanceHandler.getActuator(request);
+ Assert.assertEquals("Random",ds.withFaultInjection(loadBalance));
Review Comment:
I think for load balance do not need this complicity.
for example
```
GovernanceRequest request = new GovernanceRequest();
request.setUri("/loadrandom");
request.setServiceName("RandomTest");
LoadBalance loadBalance = loadBalanceHandler.getActuator(request);
Assert.assertEquals("Random",loadBalance.getRule());
```
This is quit enough
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939499265
##########
governance/src/main/java/org/apache/servicecomb/governance/service/MatchersServiceImpl.java:
##########
@@ -36,6 +36,9 @@ public MatchersServiceImpl(RequestProcessor requestProcessor, MatchProperties ma
@Override
public boolean checkMatch(GovernanceRequest governanceRequest, String key) {
+ if (key.equals("rule")) {
+ return true;
+ }
Review Comment:
delete this
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939532810
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/LoadBalanceImpl.java:
##########
@@ -0,0 +1,28 @@
+package org.apache.servicecomb.loadbanlance;
Review Comment:
add license
##########
governance/src/test/java/org/apache/servicecomb/governance/LoadBalancerTest.java:
##########
@@ -0,0 +1,43 @@
+package org.apache.servicecomb.governance;
Review Comment:
add license
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939499330
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/AbstractLoadbalance.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.loadbanlance;
+
+public abstract class AbstractLoadbalance implements LoadBalance {
+ protected String loadrule;
+
+ public AbstractLoadbalance(String loadrule) {
+ this.loadrule = loadrule;
+ }
+
+ @Override
+ public String choose() {
+ return choose(loadrule);
+ }
+
Review Comment:
delete this class
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939499582
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/RoundRobinBalancer.java:
##########
@@ -0,0 +1,23 @@
+package org.apache.servicecomb.loadbanlance;
+
+public class RoundRobinBalancer extends AbstractLoadbalance implements LoadBalance {
+
+ public RoundRobinBalancer(String loadrule) {
+ super(loadrule);
+ }
+
+ @Override
+ public String choose(String loadrule) {
+ return loadrule;
+ }
+
+ @Override
+ public int getOrder() {
+ return 100;
+ }
+
+ @Override
Review Comment:
delete this class
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939532508
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/LoadBalance.java:
##########
@@ -0,0 +1,29 @@
+/*
+ * 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.loadbanlance;
+
+import io.vavr.CheckedFunction0;
+
+public interface LoadBalance {
+
+ String getRule();
+
+ int getOrder();
+
+ String getName();
Review Comment:
these two methods never read, why add them?
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939532272
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/LoadBalanceImpl.java:
##########
@@ -0,0 +1,28 @@
+package org.apache.servicecomb.loadbanlance;
+
+public class LoadBalanceImpl implements LoadBalance {
+ private String rule;
+
+ public String getRule() {
+ return rule;
+ }
+
+ public void setRule(String rule) {
+ this.rule = rule;
+ }
+
+ public LoadBalanceImpl(String rule) {
+ this.rule = rule;
+ }
+
+
+ @Override
+ public int getOrder() {
+ return 100;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
Review Comment:
This two methods never read, why add them?
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939532398
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/LoadBalanceUtil.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * 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.loadbanlance;
+
+import org.apache.servicecomb.governance.policy.LoadBalancerPolicy;
+
+public class LoadBalanceUtil {
+
+ public static LoadBalance getLoadBalance(String key, LoadBalancerPolicy policy) {
+ LoadBalance loadBalance = new LoadBalanceImpl(policy.getRule());
+ return loadBalance;
+ }
+}
Review Comment:
delete this class and inline 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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939499247
##########
governance/src/main/java/org/apache/servicecomb/governance/policy/LoadBalancerPolicy.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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.policy;
+
+public class LoadBalancerPolicy extends AbstractPolicy {
+ private String loadrule;
Review Comment:
change to rule
--
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 diff in pull request #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#discussion_r939499505
##########
governance/src/main/java/org/apache/servicecomb/loadbanlance/RandomBalancer.java:
##########
@@ -0,0 +1,23 @@
+package org.apache.servicecomb.loadbanlance;
+
+public class RandomBalancer extends AbstractLoadbalance implements LoadBalance{
+
+ public RandomBalancer(String loadrule) {
+ super(loadrule);
+ }
+
+ @Override
+ public String choose(String loadrule) {
+ return loadrule;
+ }
+
+ @Override
+ public int getOrder() {
+ return 100;
+ }
+
+ @Override
+ public String getName() {
+ return LoadBalanceConst.TYPE_RANDOM;
+ }
+}
Review Comment:
do not need this
--
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 #3267: add loadbalance governance
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #3267:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3267#issuecomment-1208082334
# [Codecov](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3267?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 [#3267](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3267?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (507e1b4) into [master](https://codecov.io/gh/apache/servicecomb-java-chassis/commit/31ef85f60bab86cadf25a7c794e53d4495b70b5f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (31ef85f) will **increase** coverage by `0.01%`.
> The diff coverage is `100.00%`.
> :exclamation: Current head 507e1b4 differs from pull request most recent head e6a5b75. Consider uploading reports for the commit e6a5b75 to get more accurate results
```diff
@@ Coverage Diff @@
## master #3267 +/- ##
============================================
+ Coverage 77.44% 77.45% +0.01%
Complexity 1439 1439
============================================
Files 1641 1646 +5
Lines 43575 43596 +21
Branches 3665 3665
============================================
+ Hits 33746 33767 +21
Misses 8309 8309
Partials 1520 1520
```
| [Impacted Files](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3267?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...ervicecomb/governance/GovernanceConfiguration.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3267/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-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvZ292ZXJuYW5jZS9Hb3Zlcm5hbmNlQ29uZmlndXJhdGlvbi5qYXZh) | `100.00% <100.00%> (ø)` | |
| [...icecomb/governance/handler/LoadBalanceHandler.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3267/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-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvZ292ZXJuYW5jZS9oYW5kbGVyL0xvYWRCYWxhbmNlSGFuZGxlci5qYXZh) | `100.00% <100.00%> (ø)` | |
| [...vicecomb/governance/policy/LoadBalancerPolicy.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3267/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-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvZ292ZXJuYW5jZS9wb2xpY3kvTG9hZEJhbGFuY2VyUG9saWN5LmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...b/governance/properties/LoadBalanceProperties.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3267/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-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvZ292ZXJuYW5jZS9wcm9wZXJ0aWVzL0xvYWRCYWxhbmNlUHJvcGVydGllcy5qYXZh) | `100.00% <100.00%> (ø)` | |
| [...g/apache/servicecomb/loadbanlance/LoadBalance.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3267/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-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvbG9hZGJhbmxhbmNlL0xvYWRCYWxhbmNlLmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...ache/servicecomb/loadbanlance/LoadBalanceImpl.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3267/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-Z292ZXJuYW5jZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvbG9hZGJhbmxhbmNlL0xvYWRCYWxhbmNlSW1wbC5qYXZh) | `100.00% <100.00%> (ø)` | |
| [.../servicecomb/registry/discovery/DiscoveryTree.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3267/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-Zm91bmRhdGlvbnMvZm91bmRhdGlvbi1yZWdpc3RyeS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvcmVnaXN0cnkvZGlzY292ZXJ5L0Rpc2NvdmVyeVRyZWUuamF2YQ==) | `96.49% <0.00%> (-3.51%)` | :arrow_down: |
| [...thentication/consumer/RSAConsumerTokenManager.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3267/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-aGFuZGxlcnMvaGFuZGxlci1wdWJsaWNrZXktYXV0aC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvYXV0aGVudGljYXRpb24vY29uc3VtZXIvUlNBQ29uc3VtZXJUb2tlbk1hbmFnZXIuamF2YQ==) | `77.41% <0.00%> (+6.45%)` | :arrow_up: |
:mega: Codecov can now indicate which changes are the most critical in Pull Requests. [Learn more](https://about.codecov.io/product/feature/runtime-insights/?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