You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "heesung-sn (via GitHub)" <gi...@apache.org> on 2023/01/24 16:47:56 UTC
[GitHub] [pulsar] heesung-sn opened a new pull request, #19321: [improve][broker] Added RoundRobinBrokerSelector
heesung-sn opened a new pull request, #19321:
URL: https://github.com/apache/pulsar/pull/19321
<!--
### Contribution Checklist
- PR title format should be *[type][component] summary*. For details, see *[Guideline - Pulsar PR Naming Convention](https://docs.google.com/document/d/1d8Pw6ZbWk-_pCKdOmdvx9rnhPiyuxwq60_TrD68d7BA/edit#heading=h.trs9rsex3xom)*.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
-->
<!-- Details of when a PIP is required and how the PIP process work, please see: https://github.com/apache/pulsar/blob/master/wiki/proposals/PIP.md -->
### Motivation
Added a simple RoundRobin logic to select a broker for bundle ownership. This simple selector can help distribute the load when there are many concurrent lookup requests.
### Modifications
Added RoundRobinBrokerSelector and its unit test.
### Verifying this change
- [x] Make sure that the change passes the CI checks.
*(Please pick either of the following options)*
This change added tests and can be verified as follows:
- *Added an unit test to cover RoundRobinBrokerSelector*
### Does this pull request potentially affect one of the following parts:
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
*If the box was checked, please highlight the changes*
- [ ] Dependencies (add or upgrade a dependency)
- [ ] The public API
- [ ] The schema
- [ ] The default values of configurations
- [ ] The threading model
- [ ] The binary protocol
- [ ] The REST endpoints
- [ ] The admin CLI options
- [ ] The metrics
- [ ] Anything that affects deployment
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. Please attach the local preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR description, or else your PR might not get merged. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: https://github.com/heesung-sn/pulsar/pull/22
<!--
After opening this PR, the build in apache/pulsar will fail and instructions will
be provided for opening a PR in the PR author's forked repository.
apache/pulsar pull requests should be first tested in your own fork since the
apache/pulsar CI based on GitHub Actions has constrained resources and quota.
GitHub Actions provides separate quota for pull requests that are executed in
a forked repository.
The tests will be run in the forked repository until all PR review comments have
been handled, the tests pass and the PR is approved by a reviewer.
-->
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codecov-commenter commented on pull request #19321: [improve][broker] Added RoundRobinBrokerSelector
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #19321:
URL: https://github.com/apache/pulsar/pull/19321#issuecomment-1409803884
# [Codecov](https://codecov.io/gh/apache/pulsar/pull/19321?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 [#19321](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (c18170f) into [master](https://codecov.io/gh/apache/pulsar/commit/8d813927288a2bb4fb4806f4b0034152d5f5b5d3?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8d81392) will **increase** coverage by `0.31%`.
> The diff coverage is `54.34%`.
[](https://codecov.io/gh/apache/pulsar/pull/19321?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 #19321 +/- ##
============================================
+ Coverage 63.93% 64.24% +0.31%
- Complexity 3470 26018 +22548
============================================
Files 1818 1819 +1
Lines 133061 133132 +71
Branches 14637 14649 +12
============================================
+ Hits 85067 85529 +462
+ Misses 40270 39797 -473
- Partials 7724 7806 +82
```
| Flag | Coverage Δ | |
|---|---|---|
| inttests | `24.92% <0.00%> (-0.03%)` | :arrow_down: |
| systests | `25.56% <0.00%> (-0.15%)` | :arrow_down: |
| unittests | `61.39% <54.34%> (+0.07%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...ker/loadbalance/impl/RoundRobinBrokerSelector.java](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9sb2FkYmFsYW5jZS9pbXBsL1JvdW5kUm9iaW5Ccm9rZXJTZWxlY3Rvci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...er/authentication/OneStageAuthenticationState.java](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3B1bHNhci9icm9rZXIvYXV0aGVudGljYXRpb24vT25lU3RhZ2VBdXRoZW50aWNhdGlvblN0YXRlLmphdmE=) | `100.00% <100.00%> (ø)` | |
| [...va/org/apache/pulsar/broker/service/ServerCnx.java](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL1NlcnZlckNueC5qYXZh) | `53.62% <100.00%> (-1.30%)` | :arrow_down: |
| [.../apache/pulsar/websocket/data/ConsumerCommand.java](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLXdlYnNvY2tldC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL3dlYnNvY2tldC9kYXRhL0NvbnN1bWVyQ29tbWFuZC5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [.../impl/auth/oauth2/AuthenticationFactoryOAuth2.java](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL2F1dGgvb2F1dGgyL0F1dGhlbnRpY2F0aW9uRmFjdG9yeU9BdXRoMi5qYXZh) | `0.00% <0.00%> (-88.89%)` | :arrow_down: |
| [...a/org/apache/pulsar/client/util/TypeCheckUtil.java](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC91dGlsL1R5cGVDaGVja1V0aWwuamF2YQ==) | `0.00% <0.00%> (-83.34%)` | :arrow_down: |
| [...apache/pulsar/broker/web/MaxRequestSizeFilter.java](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci93ZWIvTWF4UmVxdWVzdFNpemVGaWx0ZXIuamF2YQ==) | `0.00% <0.00%> (-82.36%)` | :arrow_down: |
| [...pache/pulsar/broker/tools/GenerateDocsCommand.java](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci90b29scy9HZW5lcmF0ZURvY3NDb21tYW5kLmphdmE=) | `0.00% <0.00%> (-77.28%)` | :arrow_down: |
| [.../pulsar/broker/service/SharedConsumerAssignor.java](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL1NoYXJlZENvbnN1bWVyQXNzaWdub3IuamF2YQ==) | `5.55% <0.00%> (-74.08%)` | :arrow_down: |
| [...ava/org/apache/pulsar/broker/tools/BrokerTool.java](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci90b29scy9Ccm9rZXJUb29sLmphdmE=) | `0.00% <0.00%> (-71.43%)` | :arrow_down: |
| ... and [202 more](https://codecov.io/gh/apache/pulsar/pull/19321?src=pr&el=tree-more&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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Technoboy- merged pull request #19321: [improve][broker] Added RoundRobinBrokerSelector
Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- merged PR #19321:
URL: https://github.com/apache/pulsar/pull/19321
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] mattisonchao commented on a diff in pull request #19321: [improve][broker] Added RoundRobinBrokerSelector
Posted by "mattisonchao (via GitHub)" <gi...@apache.org>.
mattisonchao commented on code in PR #19321:
URL: https://github.com/apache/pulsar/pull/19321#discussion_r1095433935
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/RoundRobinBrokerSelector.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * 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.pulsar.broker.loadbalance.impl;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.loadbalance.LoadData;
+import org.apache.pulsar.broker.loadbalance.ModularLoadManagerStrategy;
+import org.apache.pulsar.policies.data.loadbalancer.BundleData;
+
+/**
+ * Simple Round Robin Broker Selection Strategy.
+ */
+public class RoundRobinBrokerSelector implements ModularLoadManagerStrategy {
+
+ final AtomicInteger count = new AtomicInteger();
+ final AtomicReference<List<String>> ref = new AtomicReference<>(List.of());
+
+ @Override
+ public Optional<String> selectBroker(Set<String> candidates, BundleData bundleToAssign, LoadData loadData,
+ ServiceConfiguration conf) {
+ int candidateSize = candidates.size();
+ if (candidateSize == 0) {
+ return Optional.empty();
+ }
+
+ var cache = ref.get();
Review Comment:
Question:
Should we ensure the thread-safe?
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Technoboy- closed pull request #19321: [improve][broker] Added RoundRobinBrokerSelector
Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- closed pull request #19321: [improve][broker] Added RoundRobinBrokerSelector
URL: https://github.com/apache/pulsar/pull/19321
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org