GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PIP-1 - Introduce Pulsar proxy component by merlimat · Pull Request #548 · apache/pulsar

Conversation

@merlimat

@merlimat merlimat commented Jul 6, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Motivation

https://github.com/apache/incubator-pulsar/wiki/PIP-1:-Pulsar-Proxy

As described in the wiki page, added a proxy component that exposes a stateless service that talk Pulsar binary protocol.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat merlimat added the type/feature The PR added a new feature or issue requested a new feature label Jul 6, 2017
@merlimat merlimat added this to the 1.19.0-incubating milestone Jul 6, 2017
@merlimat merlimat self-assigned this Jul 6, 2017
@merlimat
merlimat requested review from rdhabalia and saandrews July 6, 2017 01:16
@merlimat
PIP-1 - Introduce Pulsar proxy component
bed33fd
@merlimat
merlimat force-pushed the proxy branch from 866482a to bed33fd Compare July 6, 2017 17:39
rdhabalia
rdhabalia reviewed Jul 7, 2017
View reviewed changes
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/BinaryProtoLookupService.java
* @return broker-socket-address that serves given topic
*/
public CompletableFuture<InetSocketAddress> getBroker(DestinationName destination) {
public CompletableFuture<Pair<InetSocketAddress, InetSocketAddress>> getBroker(DestinationName destination) {

@rdhabalia rdhabalia Jul 7, 2017

Copy link
Copy Markdown
Contributor

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.

do you think using InetSocketAddress[] would be better to avoid creation of Pair object here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jul 10, 2017

Copy link
Copy Markdown
Contributor Author

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.

In this case it would be the same number of object allocations, either a Pair<> or the InetSocketAddress[]. No differences, except Pair conveys better the fact that 2 addresses are going to be there.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rdhabalia rdhabalia Jul 11, 2017

Copy link
Copy Markdown
Contributor

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.

yes, I meant avoiding creation of Pair.

conveys better the fact that 2 addresses are going to be there.

Yes, make sense.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java Outdated
private final int maxNumberOfRejectedRequestPerConnection;
private final int rejectedRequestResetTimeSec = 60;

private String targetBrokerAddress = null;

@rdhabalia rdhabalia Jul 7, 2017

Copy link
Copy Markdown
Contributor

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.

do you think if we can add proxy in the name it will easy to understand.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jul 10, 2017

Copy link
Copy Markdown
Contributor Author

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.

Sure, will rename that

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-common/src/main/proto/PulsarApi.proto Outdated
optional ServerError error = 6;
optional string message = 7;

// If it's true, indicates to the client that it must

@rdhabalia rdhabalia Jul 7, 2017

Copy link
Copy Markdown
Contributor

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.

format?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-common/src/main/proto/PulsarApi.proto
// Original principal that was verified by
// a Pulsar proxy. In this case the auth info above
// will the the auth of the proxy itself
optional string original_principal = 7;

@rdhabalia rdhabalia Jul 7, 2017

Copy link
Copy Markdown
Contributor

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.

if proxy is going to do auth&auth for original-principal then broker will not do any validation on this original_principal right? if that's true then are we passing it for debugging only? and I don't see if we are setting it in Commands.java

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jul 8, 2017

Copy link
Copy Markdown
Contributor Author

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.

Proxy is not doing authorization on the data connections. The reason is that after the initial connect/connected it just forward everything on both sides.

The broker still needs to check whether that particular role is authorized to pulblish on a specific topic. So the proxy relays the original client principal, and that will be used by the broker for the authorization, trusting that the proxy has already validated the authentication.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/DirectProxyHandler.java
if (future.isSuccess()) {
outboundChannel.read();
} else {
inboundChannel.close();

@rdhabalia rdhabalia Jul 7, 2017

Copy link
Copy Markdown
Contributor

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.

should we log warn message here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jul 10, 2017

Copy link
Copy Markdown
Contributor Author

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.

Fixed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/DirectProxyHandler.java
public void operationComplete(Future<Void> future) throws Exception {
// This is invoked when the write operation on the paired connection is completed
if (future.isSuccess()) {
outboundChannel.read();

@rdhabalia rdhabalia Jul 7, 2017

Copy link
Copy Markdown
Contributor

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.

but we have already triggered read on outboundChannel on line-107, so channel-handler will continue reading even if we don't call here. right?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jul 8, 2017

Copy link
Copy Markdown
Contributor Author

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.

No, the auto-read on the channel is set to false. The reason is to adapt to the speed of the slowest connection.

So, we read 1 buffer from c1, write into c2. When the write is completed (meaning we were able to write on the socket because the TCP send window was open), then we read the next buffer.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/LookupProxyHandler.java Outdated
brokerURI = new URI(brokerServiceUrl);
} catch (URISyntaxException e) {
proxyConnection.ctx().writeAndFlush(
Commands.newLookupErrorResponse(ServerError.ServiceNotReady, e.getMessage(), clientRequestId));

@rdhabalia rdhabalia Jul 7, 2017

Copy link
Copy Markdown
Contributor

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.

ServerError.MetadataError?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jul 10, 2017

Copy link
Copy Markdown
Contributor Author

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.

Makes more sense. Fixed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java
}

private void close() {
ctx.close();

@rdhabalia rdhabalia Jul 7, 2017

Copy link
Copy Markdown
Contributor

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.

should we have additional state= 'ConnectionClosed` ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jul 10, 2017

Copy link
Copy Markdown
Contributor Author

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.

Fixed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
merlimat added 2 commits July 10, 2017 14:33
@merlimat
Fixed formatting in proto file
a2f7ba6
@merlimat
Addressed PR comments
53e9f7e
@merlimat

merlimat commented Jul 10, 2017

Copy link
Copy Markdown
Contributor Author

@rdhabalia Addressed comments

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rdhabalia
rdhabalia reviewed Jul 11, 2017
View reviewed changes

@rdhabalia rdhabalia left a comment

Copy link
Copy Markdown
Contributor

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 .. just minor comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-proxy/src/main/resources/proxy.conf Outdated
#

# Zookeeper quorum connection string (comma-separated)
zookeeperServers=127.0.0.1:2181

@rdhabalia rdhabalia Jul 11, 2017

Copy link
Copy Markdown
Contributor

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.

in other conf file we have kept it empty. should we do the same?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jul 11, 2017

Copy link
Copy Markdown
Contributor Author

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.

Yes, I forgot these after testing

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/util/ZookeeperCacheLoader.java
private final ZooKeeperCache localZkCache;
private final LocalZooKeeperConnectionService localZkConnectionSvc;

private final ZooKeeperDataCache<LoadReport> brokerInfo;

@rdhabalia rdhabalia Jul 11, 2017

Copy link
Copy Markdown
Contributor

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.

org.apache.pulsar.policies.data.loadbalancer.ServiceLookupData because ModularLoadManager generates LocalBrokerData.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jul 11, 2017

Copy link
Copy Markdown
Contributor Author

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.

Fixed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyServiceStarter.java Outdated
DefaultExports.initialize();
server.addServlet("/metrics", new ServletHolder(MetricsServlet.class));

// server.addServlet("/*", DiscoveryServiceServlet.class, initParameters);

@rdhabalia rdhabalia Jul 11, 2017

Copy link
Copy Markdown
Contributor

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.

does this comment require for any indication?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jul 11, 2017

Copy link
Copy Markdown
Contributor Author

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.

forgot this, will remove

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java Outdated
this.serviceUrlTls = String.format("pulsar://%s:%d/", hostname, proxyConfig.getServicePortTls());

EventLoopGroup acceptorEventLoop, workersEventLoop;
if (SystemUtils.IS_OS_LINUX) {

@rdhabalia rdhabalia Jul 11, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

just a thought SystemUtils.IS_OS_LINUX && io.netty.channel.epoll.Epoll.isAvailable()?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Jul 11, 2017

Copy link
Copy Markdown
Contributor Author

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 didn't know about Epoll.isAvailable(), probably was introduced later in Netty. Then we can just use that check, no need to verify we are on Linux.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat
Addressed comments
aaf5ee2
@merlimat

merlimat commented Jul 11, 2017

Copy link
Copy Markdown
Contributor Author

@rdhabalia Updated

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rdhabalia
rdhabalia approved these changes Jul 11, 2017
View reviewed changes

@rdhabalia rdhabalia left a comment

Copy link
Copy Markdown
Contributor

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.

👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
merlimat added 2 commits July 10, 2017 23:10
@merlimat
Fixed jcommander dependency
ef27c26
@merlimat
Fixed ProducerConsumer proxy test
0979a36
@merlimat
merlimat merged commit f36b70c into apache:master Jul 11, 2017
@merlimat
merlimat deleted the proxy branch October 24, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rdhabalia rdhabalia rdhabalia approved these changes
@saandrews saandrews Awaiting requested review from saandrews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@merlimat merlimat

Labels

type/feature The PR added a new feature or issue requested a new feature

Projects

None yet

Milestone

1.19.0-incubating

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@merlimat @rdhabalia
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.