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] [client]Add new ServiceUrlProvider implementation: SameAuthParamsAutoClusterFailover #23129

Merged
merged 10 commits into from
Aug 12, 2024

Conversation

poorbarcode
Copy link
Contributor

Motivation

Background
So far, there are two implementations of ServiceUrlProvider

  • ControlledClusterFailover: call an HTTP API to change the pulsar service URL.
  • AutoClusterFailover: check the pulsar service URL by creating a socket, and automatically switch to the high-priority pulsar service URL.

Issue

  • We build two clusters c1 and c2, and start a binary-way replication between them.
  • Enabled AutoClusterFailover for our client to switch connections to the healthy cluster when the primary one can not work.
  • The network traffic is:client -> proxy -> brokers

If all the brokers crash, the proxies are still healthy, AutoClusterFailover can not determine that the primary cluster can not provide service anymore.

Modifications

Add a new ServiceUrlProvider implementation: SameAuthParamsAutoClusterFailover, which uses lookup topic to check whether the target cluster is healthy or not. Since the clusters that enabled Geo-Replication always have the same auth settings, it can be easy to implement(skipping the different auth settings ).

Documentation

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

Matching PR in forked repository

PR in forked repository: x

@poorbarcode poorbarcode added this to the 3.4.0 milestone Aug 6, 2024
@poorbarcode poorbarcode self-assigned this Aug 6, 2024
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Aug 6, 2024
@poorbarcode
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2024

Codecov Report

Attention: Patch coverage is 68.94410% with 50 lines in your changes missing coverage. Please review.

Project coverage is 74.52%. Comparing base (bbc6224) to head (ce9df7f).
Report is 510 commits behind head on master.

Files Patch % Lines
.../impl/SameAuthParamsLookupAutoClusterFailover.java 68.94% 34 Missing and 16 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23129       /-   ##
============================================
  Coverage     73.57%   74.52%    0.95%     
- Complexity    32624    33624     1000     
============================================
  Files          1877     1920       43     
  Lines        139502   144430     4928     
  Branches      15299    15804      505     
============================================
  Hits         102638   107637     4999     
  Misses        28908    28534     -374     
- Partials       7956     8259      303     
Flag Coverage Δ
inttests 27.84% <0.00%> ( 3.25%) ⬆️
systests 24.70% <0.00%> ( 0.37%) ⬆️
unittests 73.87% <68.94%> ( 1.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...g/apache/pulsar/client/api/ServiceUrlProvider.java 100.00% <ø> (ø)
.../impl/SameAuthParamsLookupAutoClusterFailover.java 68.94% <68.94%> (ø)

... and 498 files with indirect coverage changes

@poorbarcode poorbarcode merged commit 06a2f5c into apache:master Aug 12, 2024
51 checks passed
PersistentTopicInternalStats internalStats = admin.topics().getInternalStats(topicName);
ManagedLedgerInternalStats.CursorStats cursorStats2 = internalStats.cursors.get("s2");
String[] ledgerIdAndEntryId2 = cursorStats2.markDeletePosition.split(":");
ImmutablePositionImpl actMarkDeletedPos2 =
Copy link
Member

Choose a reason for hiding this comment

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

There shouldn't be a need to use ImmutablePositionImpl in code. Simply use Position as the type and PositionFactory to create instances. They will be immutable by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

log.info("Expected mark deleted position: {}", expectedMarkDeletedPos);
log.info("Actual mark deleted position: {}", cursorStats.markDeletePosition);
assertTrue(actMarkDeletedPos.compareTo(expectedMarkDeletedPos) >= 0);
AssertJUnit.assertTrue(actMarkDeletedPos.compareTo(expectedMarkDeletedPos) >= 0);
Copy link
Member

Choose a reason for hiding this comment

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

AssertJUnit shouldn't be needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of this test in this PR? Is it unrelated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lhotari pushed a commit that referenced this pull request Aug 14, 2024
…ParamsAutoClusterFailover (#23129)

- excluding changes to pulsar-broker/src/test/java/org/apache/pulsar/client/api/NonDurableSubscriptionTest.java
  PR #23168

(cherry picked from commit 06a2f5c)
lhotari pushed a commit that referenced this pull request Aug 14, 2024
…ParamsAutoClusterFailover (#23129)

(cherry picked from commit 06a2f5c)
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 16, 2024
…ParamsAutoClusterFailover (apache#23129)

- excluding changes to pulsar-broker/src/test/java/org/apache/pulsar/client/api/NonDurableSubscriptionTest.java
  PR apache#23168

(cherry picked from commit 06a2f5c)
(cherry picked from commit 286a5dc)
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 16, 2024
…ParamsAutoClusterFailover (apache#23129)

- excluding changes to pulsar-broker/src/test/java/org/apache/pulsar/client/api/NonDurableSubscriptionTest.java
  PR apache#23168

(cherry picked from commit 06a2f5c)
(cherry picked from commit 286a5dc)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 20, 2024
…ParamsAutoClusterFailover (apache#23129)

- excluding changes to pulsar-broker/src/test/java/org/apache/pulsar/client/api/NonDurableSubscriptionTest.java
  PR apache#23168

(cherry picked from commit 06a2f5c)
(cherry picked from commit 286a5dc)
Technoboy- pushed a commit that referenced this pull request Aug 22, 2024
grssam pushed a commit to grssam/pulsar that referenced this pull request Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants