Skip to content
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 updated metrics and cleanup broker selector #19945

Merged
merged 11 commits into from
Apr 5, 2023

Conversation

heesung-sn
Copy link
Contributor

Master Issue: #16691

Motivation

Raising a PR to implement: #16691

Modifications

This PR

  • Added Override EventType metrics
  • Made ExtensibleLoadManager.selectAsync for cleanup broker selector.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • *Updated unit tests.

Does this pull request potentially affect one of the following parts:

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
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

We will have separate PRs to update the Doc later.

Matching PR in forked repository

PR in forked repository: heesung-sn#40

Sorry, something went wrong.

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Mar 28, 2023
@Demogorgon314 Demogorgon314 self-requested a review March 29, 2023 02:23
@heesung-sn heesung-sn force-pushed the pip-192-update-metrics branch from 92a9f59 to 131868d Compare March 29, 2023 22:34
@heesung-sn
Copy link
Contributor Author

Raised a load-balance dashboard PR here. streamnative/apache-pulsar-grafana-dashboard#93

@heesung-sn heesung-sn force-pushed the pip-192-update-metrics branch from 131868d to 05d3e4b Compare March 29, 2023 23:16
Optional<String> selectedBroker = brokerSelector.select(availableBrokers, null, context);
private Optional<String> selectBroker(String serviceUnit) {
var namespaceBundle = getNamespaceBundle(serviceUnit);
if (namespaceBundle.getNamespaceObject().equals(SYSTEM_NAMESPACE)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need to skip bundles of the system namespace? I found the method ExtensibleLoadManagerImpl#assign will ignore some internal topics and use the channel owner as the owner broker.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. We shouldn't. Updated.

private final PulsarService pulsar;
private final ServiceConfiguration config;
private final Schema<ServiceUnitStateData> schema;
private final ConcurrentOpenHashMap<String, CompletableFuture<String>> getOwnerRequests;
private final String lookupServiceAddress;
private final ConcurrentOpenHashMap<String, CompletableFuture<Void>> cleanupJobs;
private final StateChangeListeners stateChangeListeners;
private BrokerSelectionStrategy brokerSelector;
private ExtensibleLoadManagerImpl brokerSelector;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change the field name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

@@ -329,9 +337,9 @@ protected LoadManagerContext getContext() {
}

@VisibleForTesting
protected BrokerSelectionStrategy getBrokerSelector() {
protected ExtensibleLoadManagerImpl getBrokerSelector() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the previous comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

+ " This broker is not the owner.", bundle));
counter.update(Failure, Unknown);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need update counter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This can happen a lot, and we don't want to add noise in failure count.

@heesung-sn
Copy link
Contributor Author

@gaoran10 @Demogorgon314 PTAL by any chance.

@@ -465,7 +472,7 @@ public CompletableFuture<Optional<String>> getOwnerAsync(String serviceUnit) {

ServiceUnitStateData data = tableview.get(serviceUnit);
ServiceUnitState state = state(data);
ownerLookUpCounters.get(state).incrementAndGet();
ownerLookUpCounters.get(state).total.incrementAndGet();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ownerLookUpCounters.get(state).total.incrementAndGet();
ownerLookUpCounters.get(state).getTotal().incrementAndGet();

Copy link
Contributor Author

@heesung-sn heesung-sn Apr 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

return deferGetOwnerRequest(serviceUnit).thenApply(
return deferGetOwnerRequest(serviceUnit).whenComplete((__, e) -> {
if (e != null) {
ownerLookUpCounters.get(state).failure.incrementAndGet();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ownerLookUpCounters.get(state).failure.incrementAndGet();
ownerLookUpCounters.get(state).getFailure().incrementAndGet();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

broker -> broker == null ? Optional.empty() : Optional.of(broker));
}
case Init, Free -> {
return CompletableFuture.completedFuture(Optional.empty());
}
case Deleted -> {
ownerLookUpCounters.get(state).failure.incrementAndGet();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ownerLookUpCounters.get(state).failure.incrementAndGet();
ownerLookUpCounters.get(state).getFailure().incrementAndGet();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

return CompletableFuture.failedFuture(new IllegalArgumentException(serviceUnit + " is deleted."));
}
default -> {
ownerLookUpCounters.get(state).failure.incrementAndGet();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ownerLookUpCounters.get(state).failure.incrementAndGet();
ownerLookUpCounters.get(state).getFailure().incrementAndGet();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

@heesung-sn
Copy link
Contributor Author

@gaoran10 @Technoboy- PTAL by any chance.

@lhotari
Copy link
Member

lhotari commented Apr 5, 2023

/pulsarbot rerun-failure-checks

@Technoboy- Technoboy- merged commit 32e677d into apache:master Apr 5, 2023
@Technoboy- Technoboy- added this to the 3.0.0 milestone Apr 5, 2023
@heesung-sn heesung-sn deleted the pip-192-update-metrics branch April 2, 2024 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker doc-not-needed Your PR changes do not impact docs ready-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants