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 — [pulsar-broker] PIP-100 Support pluggable topic factory by rdhabalia · Pull Request #12235 · apache/pulsar

Conversation

@rdhabalia

@rdhabalia rdhabalia commented Sep 29, 2021

Copy link
Copy Markdown
Contributor

Motivation

Users select the topic type based on the application use case and requirement of topic behavior. However, in some circumstances, users need some additional behavior on top of the existing implementation and even would like to inject custom workflow in existing topic behavior. Such special circumstances are mostly needed when users would like to do smooth migrations of topics or pulsar clusters without impacting producer and consumer applications. In such scenarios, users can override publish or dispatch behavior of the topic and plug in the additional workflow. For example: perform dual write on multiple topics while migration or, skip messages published from the specific source without explicit publish failures, ignore specific subscription source without generating a client-side error, or without impacting client applications. This feature will be useful for any kind of migration where the pulsar cluster is serving live topics and require custom topic level treatment for flawless server-side migration and without impacting client application especially legacy applications which are hard to change.

Modification

  • Add broker side config topicFactoryClassName and TopicFactory interface.
  • Mark feature is an experimental feature to accommodate future API changes.

Result

  • Users can create topic with custom workflow for their server-side migration usecases.

Sorry, something went wrong.

Uh oh!

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

All reactions
@rdhabalia rdhabalia added the area/broker label Sep 29, 2021
@rdhabalia rdhabalia added this to the 2.9.0 milestone Sep 29, 2021
@rdhabalia
rdhabalia requested review from codelipenghui, eolivelli, jiazhai, merlimat and sijie September 29, 2021 05:47
@rdhabalia rdhabalia self-assigned this Sep 29, 2021
@rdhabalia
rdhabalia force-pushed the topic_factory branch from e3d3d2e to 649af8f Compare September 29, 2021 05:49
@Anonymitaet

Anonymitaet commented Sep 30, 2021

Copy link
Copy Markdown
Member

Thanks for your contribution. For this PR, do we need to update docs?

(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

All reactions

Sorry, something went wrong.

Uh oh!

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

@eolivelli eolivelli modified the milestones: 2.9.0, 2.10.0 Oct 6, 2021
@rdhabalia

rdhabalia commented Nov 20, 2021

Copy link
Copy Markdown
Contributor Author

ping

All reactions

Sorry, something went wrong.

Uh oh!

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

eolivelli
eolivelli requested changes Nov 20, 2021
View reviewed changes

@eolivelli eolivelli 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.

I left one comment on the API, can you please take a look ?

Generally I am not a fan of this kind of features because we allow users to interact with the internals of Pulsar and tweak the behaviour using the internal APIs that are not expected to be "maintained", I mean, that we can change from version to version (even point releases).

We are already full of this injection points, so I am not going to block this.
My "request changes" is about my comment to add a "close" method to the API

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicFactory.java
*/
public interface TopicFactory {

<T extends Topic> T create(String topic, ManagedLedger ledger, BrokerService brokerService, Class<T> topicClazz);

@eolivelli eolivelli Nov 20, 2021

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 add a close method ?
this will allow cleanup operations

Sorry, something went wrong.

Uh oh!

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

All reactions

@rdhabalia rdhabalia Dec 20, 2021

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.

@eolivelli addressed it.

Sorry, something went wrong.

Uh oh!

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

All reactions

@rdhabalia rdhabalia Dec 21, 2021

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.

extended Closeable interface

Sorry, something went wrong.

Uh oh!

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

All reactions
@rdhabalia
rdhabalia force-pushed the topic_factory branch 2 times, most recently from 566d2ad to 46c5ecf Compare December 17, 2021 03:50
@rdhabalia

rdhabalia commented Dec 21, 2021

Copy link
Copy Markdown
Contributor Author

@eolivelli addressed the comment. can you PTAL and unblock the PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

@rdhabalia

rdhabalia commented Jan 8, 2022

Copy link
Copy Markdown
Contributor Author

ping. @eolivelli can you please unblock the PR if your concern is addressed.

All reactions

Sorry, something went wrong.

Uh oh!

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

eolivelli
eolivelli requested changes Jan 9, 2022
View reviewed changes

@eolivelli eolivelli 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.

Hello @rdhabalia
Sorry for late reply
I read again the patch and I found that the new close method is not called, and I also added a couple of important comments in my opinion.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicE2ETest.java

@Override
public void close() throws IOException {
// No-op

@eolivelli eolivelli Jan 9, 2022

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.

Please verify the number of calls to this method

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java Outdated
return (T) newTopic;
}
} catch (Throwable e) {
log.warn("Failed to create persistent topic using factory {}, {}", topic, e.getMessage());

@eolivelli eolivelli Jan 9, 2022

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.

Here we should fail otherwise the system will be using the default implementation, leading to unpredictable behaviour

Sorry, something went wrong.

Uh oh!

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

All reactions

@rdhabalia rdhabalia Feb 9, 2022

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.

actually handling the exception and falling back to default implementation strategy was intentional to avoid unavailability of topic. however, I have updated it to throw exception for now so, we can merge this PR as it's open for almost 6 months now.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
.newSingleThreadScheduledExecutor(new DefaultThreadFactory("pulsar-backlog-quota-checker"));
this.authenticationService = new AuthenticationService(pulsar.getConfiguration());
this.blockedDispatchers = new ConcurrentOpenHashSet<>();
this.topicFactory = createPersistentTopicFactory();

@eolivelli eolivelli Jan 9, 2022

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.

We are not shutting down (calling 'close') the new instance

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
try {
return (TopicFactory) Class.forName(topicFactoryClassName).newInstance();
} catch (Exception e) {
log.warn("Failed to initialize topic factory class {}", topicFactoryClassName, e);

@eolivelli eolivelli Jan 9, 2022

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.

We should fail, otherwise the system will use the default configuration, leading to unexpected behaviour

Sorry, something went wrong.

Uh oh!

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

All reactions
@codelipenghui codelipenghui modified the milestones: 2.10.0, 2.11.0 Jan 18, 2022
@rdhabalia
rdhabalia force-pushed the topic_factory branch from c905b37 to 7432bfb Compare February 9, 2022 18:31
@rdhabalia

rdhabalia commented Feb 9, 2022

Copy link
Copy Markdown
Contributor Author

@eolivelli addressed the comments. please unblock when get a chance.

All reactions

Sorry, something went wrong.

Uh oh!

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

@rdhabalia

rdhabalia commented Feb 11, 2022

Copy link
Copy Markdown
Contributor Author

@eolivelli ping

All reactions

Sorry, something went wrong.

Uh oh!

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

@rdhabalia

rdhabalia commented Mar 7, 2022

Copy link
Copy Markdown
Contributor Author

ping

All reactions

Sorry, something went wrong.

Uh oh!

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

@rdhabalia rdhabalia mentioned this pull request Jun 9, 2022
[feat] [broker] support broker isolation for uniform load shedder strategy #13080
Closed
eolivelli
eolivelli approved these changes Jul 20, 2022
View reviewed changes
@rdhabalia
rdhabalia force-pushed the topic_factory branch from f3ce1ed to de60f40 Compare July 20, 2022 06:38
@rdhabalia
[pulsar-broker] PIP-100 Support pluggable topic factory
31bb049
add Closeable

fix test

close factory and handle exception
@rdhabalia
rdhabalia force-pushed the topic_factory branch from de60f40 to 31bb049 Compare July 20, 2022 16:31
@rdhabalia
rdhabalia merged commit 6f38c5a into apache:master Jul 20, 2022
@momo-jun

momo-jun commented Aug 19, 2022

Copy link
Copy Markdown
Contributor

Hi @rdhabalia, just wanted to check in on the docs because it didn't attach any doc label. Does it require to add or update any docs to help users better understand it? Thanks.

All reactions

Sorry, something went wrong.

Uh oh!

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

@momo-jun momo-jun added the doc-required Your PR changes impact docs and you will update later. label Jan 18, 2023
@momo-jun

momo-jun commented Jan 18, 2023

Copy link
Copy Markdown
Contributor

Since the content gap still exists, I attached the doc-required label for further tracking and fixing.
//cc @Technoboy-

All reactions

Sorry, something went wrong.

Uh oh!

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

@chiragbparikh

chiragbparikh commented May 4, 2023

Copy link
Copy Markdown

@momo-jun and @rdhabalia Can we please get some documentation and clarification on how this feature can be used for Migration of topics and migration of topics across clusters?

All reactions

Sorry, something went wrong.

Uh oh!

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

@momo-jun

momo-jun commented May 30, 2023

Copy link
Copy Markdown
Contributor

@chiragbparikh, thanks for asking.
@rdhabalia, it would be great if you could provide docs to help users better understand this feature. If a feature is not documented, it doesn't exist :)

All reactions

Sorry, something went wrong.

Uh oh!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@eolivelli eolivelli eolivelli approved these changes
@merlimat merlimat Awaiting requested review from merlimat
@sijie sijie Awaiting requested review from sijie
@jiazhai jiazhai Awaiting requested review from jiazhai
@codelipenghui codelipenghui Awaiting requested review from codelipenghui

Uh oh!

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

Assignees

@rdhabalia rdhabalia

Labels

area/broker doc-required Your PR changes impact docs and you will update later.

Projects

None yet

Milestone

2.11.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

6 participants

@rdhabalia @Anonymitaet @momo-jun @chiragbparikh @eolivelli @codelipenghui
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.