-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[improve][broker] PIP-192: Define new load manager base interfaces #18084
[improve][broker] PIP-192: Define new load manager base interfaces #18084
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, this looks great to me.
I have some minor general comments.
- let's trim some of the public functions in these interfaces if not used.
- let's use generic terms, e.g.
service unit
instead ofbundle
(so that the functionality can be more "extensible"). - let's try to use
record
classes as much as we can.
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensible/BrokerRegistry.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensible/BrokerRegistry.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensible/BrokerRegistry.java
Outdated
Show resolved
Hide resolved
...ker/src/main/java/org/apache/pulsar/broker/loadbalance/extensible/ExtensibleLoadManager.java
Outdated
Show resolved
Hide resolved
...ker/src/main/java/org/apache/pulsar/broker/loadbalance/extensible/ExtensibleLoadManager.java
Outdated
Show resolved
Hide resolved
...r/src/main/java/org/apache/pulsar/broker/loadbalance/extensible/data/TopBundlesLoadData.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensible/models/Split.java
Outdated
Show resolved
Hide resolved
...roker/src/main/java/org/apache/pulsar/broker/loadbalance/extensible/store/LoadDataStore.java
Outdated
Show resolved
Hide resolved
...r/src/test/java/org/apache/pulsar/broker/loadbalance/extensible/data/BrokerLoadDataTest.java
Outdated
Show resolved
Hide resolved
...roker/src/main/java/org/apache/pulsar/broker/loadbalance/extensible/data/BrokerLoadData.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensible/BrokerRegistry.java
Outdated
Show resolved
Hide resolved
Hi,
I am not sure pulsar follows this naming convention, but I think we can
make a creative name for this project and use it as the package name, like
org.apache.pulsar.broker.loadbalance.(project name).
I propose “Overlord”.
org.apache.pulsar.broker.loadbalance.overlord
Origin:
https://starcraft.fandom.com/wiki/Overlord
I am also ok with
org.apache.pulsar.broker.loadbalance.extensions or
org.apache.pulsar.broker.loadbalance.extensible.
Thanks,
Heesung
…On Tue, Nov 8, 2022 at 5:19 AM Kai Wang ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensible/BrokerRegistry.java
<#18084 (comment)>:
> + * 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.extensible;
I will more prefer to use org.apache.pulsar.broker.loadbalance.extensions
or org.apache.pulsar.broker.loadbalance.extensible.
@heesung-sn <https://github.com/heesung-sn> Do you have any other
opinions?
—
Reply to this email directly, view it on GitHub
<#18084 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYVJ675AMK74H72NFMJEDUTWHJHPTANCNFSM6AAAAAARHZDICI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Sorry, my last email got corrupted. Here is the corrected one.
I am not sure pulsar follows this naming convention, but I think we can
make
a creative name for this project and use it as the package name, like
org.apache.pulsar.broker.loadbalance.(project name).
I propose “Overlord”.
org.apache.pulsar.broker.loadbalance.overlord
Origin:
https://starcraft.fandom.com/wiki/Overlord
I am also ok with
org.apache.pulsar.broker.loadbalance.extensions
or org.apache.pulsar.broker.loadbalance.extensible.
Thanks,
Heesung
On Tue, Nov 8, 2022 at 8:38 AM Heesung Sohn ***@***.***>
wrote:
… Hi,
I am not sure pulsar follows this naming convention, but I think we can
make a creative name for this project and use it as the package name, like
org.apache.pulsar.broker.loadbalance.(project name).
I propose “Overlord”.
org.apache.pulsar.broker.loadbalance.overlord
Origin:
https://starcraft.fandom.com/wiki/Overlord
I am also ok with
org.apache.pulsar.broker.loadbalance.extensions or
org.apache.pulsar.broker.loadbalance.extensible.
Thanks,
Heesung
On Tue, Nov 8, 2022 at 5:19 AM Kai Wang ***@***.***> wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In
> pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensible/BrokerRegistry.java
> <#18084 (comment)>:
>
> > + * 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.extensible;
>
> I will more prefer to use org.apache.pulsar.broker.loadbalance.extensions
> or org.apache.pulsar.broker.loadbalance.extensible.
>
> @heesung-sn <https://github.com/heesung-sn> Do you have any other
> opinions?
>
> —
> Reply to this email directly, view it on GitHub
> <#18084 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AYVJ675AMK74H72NFMJEDUTWHJHPTANCNFSM6AAAAAARHZDICI>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
@heesung-sn Use |
Il Mer 9 Nov 2022, 08:21 Kai Wang ***@***.***> ha scritto:
@heesung-sn <https://github.com/heesung-sn> Use
org.apache.pulsar.broker.loadbalance.overlord ok to me.
I am not sure.
We are not used to this kind of creative names. We could do it but I prefer
something that is meaningful for users.
I would go with .extensions
Enrico
… —
Reply to this email directly, view it on GitHub
<#18084 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACIHZNUSI4NFG67RF2GUNHLWHNGGRANCNFSM6AAAAAARHZDICI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
ok. I am fine with `.extensions` too.
Thanks,
Heesung
…On Wed, Nov 9, 2022 at 1:16 PM Enrico Olivelli ***@***.***> wrote:
Il Mer 9 Nov 2022, 08:21 Kai Wang ***@***.***> ha scritto:
> @heesung-sn <https://github.com/heesung-sn> Use
> org.apache.pulsar.broker.loadbalance.overlord ok to me.
>
I am not sure.
We are not used to this kind of creative names. We could do it but I prefer
something that is meaningful for users.
I would go with .extensions
Enrico
> —
> Reply to this email directly, view it on GitHub
> <#18084 (comment)>,
or
> unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/ACIHZNUSI4NFG67RF2GUNHLWHNGGRANCNFSM6AAAAAARHZDICI
>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
—
Reply to this email directly, view it on GitHub
<#18084 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYVJ674I3LHUL2PZFJDNN73WHQIB3ANCNFSM6AAAAAARHZDICI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
5e7dad5
to
2458fbe
Compare
2458fbe
to
07e8ab9
Compare
...roker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/filter/BrokerFilter.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to add line breaks to all files. If you are using Intellij Idea, Go to Editor - General
, click Ensure every saved file ends with a line break
.
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/BrokerRegistry.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/BrokerRegistry.java
Show resolved
Hide resolved
07e8ab9
to
5cb7b56
Compare
Codecov Report
@@ Coverage Diff @@
## master #18084 +/- ##
=============================================
- Coverage 45.62% 30.05% -15.57%
+ Complexity 10075 6824 -3251
=============================================
Files 697 762 +65
Lines 68024 72901 +4877
Branches 7293 7812 +519
=============================================
- Hits 31033 21911 -9122
- Misses 33413 47978 +14565
+ Partials 3578 3012 -566
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/** | ||
* Defines the information required to broker lookup. | ||
*/ | ||
public record BrokerLookupData (String webServiceUrl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer PIP-192, this record should be LocalBrokerData
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, BrokerLookupData
maybe better since we already have a LocalBrokerData
class (it contains lookup data and load data) in the old load manager impl. This record should only have lookup data.
The load data has split to BrokerLoadData
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your explain. Maybe we can change PIP-192.
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/BrokerRegistry.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/BrokerRegistry.java
Outdated
Show resolved
Hide resolved
* @param serviceUnit service unit (e.g. bundle). | ||
* @return Simple resource. | ||
*/ | ||
CompletableFuture<Optional<LookupResult>> assign(Optional<ServiceUnitId> topic, ServiceUnitId serviceUnit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who is to invoke this method? Should the method return BrokerLookupData
? We should minimize coupling with the current implementation.
...ain/java/org/apache/pulsar/broker/loadbalance/extensions/scheduler/LoadManagerScheduler.java
Show resolved
Hide resolved
...roker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/store/LoadDataStore.java
Show resolved
Hide resolved
/** | ||
* Async push load data to store. | ||
* | ||
* @param key The load data key. (e.g. bundle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the elements of a bundle? Should there be a namespace to distinguish?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is just an example. Actually, we always use the broker lookup service address as the key. I will remove this example, and explain it in impl class.
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/BrokerRegistry.java
Outdated
Show resolved
Hide resolved
Lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have left only one major comment, apart from that I am +1 to this patch
* @param pulsarService Pulsar service to use. | ||
* @return A set of the bundles that should be split. | ||
*/ | ||
Set<Split> findBundlesToSplit(LoadManagerContext context, PulsarService pulsarService); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to pass PulsarService pulsarService here ?
it is not an "interface" so we are leaking some "implementation details"
in any case....won't it be injected to implementations at construction time ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/BrokerRegistry.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/BrokerRegistry.java
Outdated
Show resolved
Hide resolved
...roker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/data/BrokerLoadData.java
Show resolved
Hide resolved
*/ | ||
@Data | ||
public class BrokerLoadData { | ||
private static final double gigaBitToByte = 128 * 1024 * 1024.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have org.apache.pulsar.client.api.SizeUnit
I think we can add a method in SizeUnit
public double toBytes(double value) {
return value * bytes;
}
And use the SizeUnit directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed some temporary unused methods from BrokerLoadData
. I think we can add it when we use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping @codelipenghui
private static double maxWithinLimit(double limit, double...args) { | ||
double max = 0.0; | ||
for (double d : args) { | ||
if (d > max && d <= limit) { | ||
max = d; | ||
} | ||
} | ||
return max; | ||
} | ||
|
||
private static double max(double...args) { | ||
double max = Double.NEGATIVE_INFINITY; | ||
|
||
for (double d : args) { | ||
if (d > max) { | ||
max = d; | ||
} | ||
} | ||
|
||
return max; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated with LocalBrokerData
public double getMaxResourceUsageWithExtendedNetworkSignal(ServiceConfiguration conf) { | ||
|
||
double nicSpeedBytesInSec = getNicSpeedBytesInSec(conf); | ||
return maxWithinLimit(100.0d, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we can't apply the limitation of resource usage.
#18598 has provided more details.
pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/LocalBrokerData.java
Outdated
Show resolved
Hide resolved
6534ce0
to
8e2240e
Compare
…pache#18084) Master Issue: apache#16691 ### Motivation We will start raising PRs to implement PIP-192, apache#16691 ### Modifications The PR adds base classes for the new broker load balance project and does not integrate with the existing load balance logic. This PR should not impact the existing broker load balance behavior. For the pip-192 project, this PR * defines the base interface under `org.apache.pulsar.broker.loadbalance.extensible` package. * defines this `BrokerRegistry` public interface and its expected behaviors. * defines `BrokerFilter` interfaces. * defines `LoadDataReporter` interfaces. * defines `NamespaceBundleSplitStrategy` interfaces. * defines `LoadManagerScheduler` interfaces. * defines `NamespaceUnloadStrategy` interfaces. * defines `LoadDataStore` interfaces. * defines `ExtensibleLoadManager` interfaces. * defines `LoadManagerContext` interfaces. * defines `BrokerLoadData` and `BrokerLookupData` data classes.
Master Issue: #16691
Motivation
We will start raising PRs to implement PIP-192, #16691
Modifications
The PR adds base classes for the new broker load balance project and does not integrate with the existing load balance logic. This PR should not impact the existing broker load balance behavior.
For the pip-192 project, this PR
org.apache.pulsar.broker.loadbalance.extensible
package.BrokerRegistry
public interface and its expected behaviors.BrokerFilter
interfaces.LoadDataReporter
interfaces.NamespaceBundleSplitStrategy
interfaces.LoadManagerScheduler
interfaces.NamespaceUnloadStrategy
interfaces.LoadDataStore
interfaces.ExtensibleLoadManager
interfaces.LoadManagerContext
interfaces.BrokerLoadData
andBrokerLookupData
data classes.Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: Demogorgon314#4