Skip to content

Support Topic lookup using Pulsar binary protocol - #5

Merged
merlimat merged 1 commit into
apache:masterfrom
rdhabalia:lookup
Nov 9, 2016
Merged

Support Topic lookup using Pulsar binary protocol#5
merlimat merged 1 commit into
apache:masterfrom
rdhabalia:lookup

Conversation

@rdhabalia

@rdhabalia rdhabalia commented Sep 10, 2016

Copy link
Copy Markdown
Contributor

Motivation

To improve lookup performance: adding lookup API in Pulsar binary protocol for:

  • PartitionedTopicMetadata
  • Topic-lookup: find BrokerService-Url

Modifications

  • Introduced two new protobuf-commands for partitionedMetadata and topic lookup
  • server/client api to handle lookup request/response

Result

Result: Client-library can do topic-lookup using pulsar binary protocol.

@yahoocla

Copy link
Copy Markdown

CLA is valid!

@rdhabalia rdhabalia changed the title CMS-1920 TCP: PartitionMetadata-Lookup + Topic-Broker lookup TCP: Topic lookup Sep 10, 2016
@rdhabalia rdhabalia added this to the 1.15 milestone Sep 10, 2016
@rdhabalia rdhabalia self-assigned this Sep 10, 2016
@rdhabalia rdhabalia added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Sep 10, 2016
@rdhabalia rdhabalia changed the title TCP: Topic lookup Support Topic lookup using Pulsar binary protocol Sep 10, 2016

@merlimat merlimat Sep 10, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should use the http & https urls from the report here (all 4 the urls)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually in this case, returned LookupResult contains redirect urls.

  • Http lookup request just requires broker-url where call should be redirected. So, LookupResult has one http/https url
  • Binary-Protocol request sends both broker service-url/tls and client decides which one needs to be selected based on client configuration.

@rdhabalia
rdhabalia force-pushed the lookup branch 2 times, most recently from e254af3 to ff3c89b Compare September 12, 2016 17:38

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should abstract the LookupService to have 2 different implementation instead of relying on the flag.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes.. made the change to abstract LookupService.

@rdhabalia
rdhabalia force-pushed the lookup branch 8 times, most recently from e5dcb7a to f37db88 Compare September 15, 2016 01:34

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change is already in the other PR #11

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes..we picked up the same commit to unblock this enhancement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That PR is merged, so you can just rebase to get rid of the commit from this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't we return the broker address if the bundle is already owned? If I'm not wrong, we only redirect the request if the bundle is not owned.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes.. that is correct. added that point in comment as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we put these validation checks in separate methods maybe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

actually, we have already abstracted all validation. and each validation step: we are returning different LookupResponse-ByteBuf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you confirm if removing this will be backward compatible?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes.. as we were not returning httpRedirectAddress to client and it was being used in internal method to find out final returning result.

  • If Type== HttpRedirectUrl then redirect-http request to URL httpRedirectAddress.

However, in new change all urls service/web-service/tls will be part of LookupData and redirection will be determined using RedirectUrl type.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove this line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed comment..

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This method is already there in AdminResource.java

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

handlePartitionRequest -> handlePartitionMetadataRequest

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

alright.. renamed the method name.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't we reuse the POJO that we already have for LookupResult

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LookupResult POJO is being used to return Lookup result by Broker-http-lookup. However, to implement Lookup-Response-handling in binary-protocol lookup we need few more additional attributes such as authoritative, redirect, partitions. So, we have this POJO at client side to handle Future.Response for topic-lookup and partition-lookup

@rdhabalia
rdhabalia force-pushed the lookup branch 7 times, most recently from d6b782e to 76094a4 Compare September 20, 2016 01:24
@merlimat merlimat modified the milestones: 1.16, 1.15 Oct 8, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This deserializer could be made static

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could actually fail for multiple reasons :) (invalid auth, no zk session.. etc )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, lookupDestinationAsync(..) handles all failure scenarios (auth, no zk session,..) and always returns appropriate ByteBuf with specific error-response. therefore, future should not complete with exception.

I have addressed all other comments as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you wrap this log.debug() call with the if (log.isDebugEnabled())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

serviceAddress can be final

@merlimat

merlimat commented Nov 9, 2016

Copy link
Copy Markdown
Contributor

@rdhabalia There seems to be a conflict with master in the latest push

@merlimat merlimat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@merlimat
merlimat merged commit 004e022 into apache:master Nov 9, 2016
@rdhabalia
rdhabalia deleted the lookup branch January 23, 2017 22:04
merlimat referenced this pull request in merlimat/pulsar Jul 7, 2017
* add protobuf.json to git

* make protobuf doc generation static
sijie referenced this pull request in sijie/pulsar Mar 4, 2018
hrsakai pushed a commit to hrsakai/pulsar that referenced this pull request Dec 10, 2020
hangc0276 referenced this pull request in hangc0276/pulsar May 26, 2021
)

*Motivation*

Use a customized version slows down the development.

*Modifications*

- Change to use reflection to access private fields and methods
- Add license headers
- Delete unneeded filees

*Verify this change*

- Enable CI
@zhcn zhcn mentioned this pull request Aug 25, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants