Skip to content

Conversation

@lifepuzzlefun
Copy link
Contributor

@lifepuzzlefun lifepuzzlefun commented Jun 1, 2023

Motivation

Current when PulsarAdmin is create on the broker side. the internal async http client will create its own netty eventloop, netty timer and one ScheduledExecutorService. maybe we can just reuse the broker side resources like PulsarClient.

Modifications

  1. create one parameter pass object SharedExecutorContext to save eventloop, timer, and schedulerExecutor.
  2. add configuration in PulsarAdminBuilderImpl.
  3. pass those object to AsyncHttpConnectorProvider
  4. set those object when create AsyncHttpClient
  5. AsyncHttpClient has its own logic to check if the eventloop and timer is provided by the api caller
    which prevent those object to be closed.

Verifying this change

This change is already covered by existing tests, such as (please describe 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
  • The metrics
  • Anything that affects deployment

Documentation

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

Matching PR in forked repository

PR in forked repository: lifepuzzlefun#19

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jun 1, 2023
Comment on lines 332 to 348

/**
* This override the pulsar admin client
* netty EventLoopGroup when admin is created on the broker side.
* @param eventLoopGroup
* @return this
*/
PulsarAdminBuilder setEventLoopGroup(EventLoopGroup eventLoopGroup);

/**
* This override the pulsar admin client
* netty Timer when admin is created on the broker side.
* @param nettyTimer
* @return this
*/
PulsarAdminBuilder setNettyTimer(Timer nettyTimer);

Copy link
Member

Choose a reason for hiding this comment

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

This cannot be exposed on the public API. It will cause issues on the shaded client since the Netty packages are shaded. The decision has been to hide this type of details from the public API.

Please see PIP-234 discussion about this: https://lists.apache.org/thread/5jw06hqlmwnrgvbn9lfom1vkwhwqwwd4 .

A temporary solution is to make this possible in the private API such as has been done for the Pulsar Client currently. Hopefully we eventually find a solution for PIP-234. The design hasn't been completed.

Copy link
Member

Choose a reason for hiding this comment

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

@lifepuzzlefun
Copy link
Contributor Author

lifepuzzlefun commented Jun 1, 2023

@lhotari Thank you so much for providing background links. I hide those share resource method in the PulsarAdminBuilderImpl now

@lifepuzzlefun lifepuzzlefun force-pushed the reuse_timer_and_eventloop branch from 80270b9 to fc54774 Compare June 2, 2023 03:39
@lifepuzzlefun lifepuzzlefun changed the title [improve][broker] Reuse netty timer and eventloop for broker side PulsarAdminImpl [improve][broker] Reuse io eventloop and other executors for broker side PulsarAdminImpl Jun 2, 2023
@lifepuzzlefun
Copy link
Contributor Author

all unit test pass in my local repo except coverage upload see lifepuzzlefun#19

@lifepuzzlefun lifepuzzlefun requested a review from lhotari June 3, 2023 04:30
@lifepuzzlefun lifepuzzlefun force-pushed the reuse_timer_and_eventloop branch from 757b0e2 to e3249dd Compare June 6, 2023 14:45
@lifepuzzlefun
Copy link
Contributor Author

@lhotari Hi, I have changed the code, PTAL : -)

@github-actions
Copy link

github-actions bot commented Jul 8, 2023

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions bot added the Stale label Jul 8, 2023
@Technoboy- Technoboy- added this to the 3.2.0 milestone Jul 31, 2023
@Technoboy- Technoboy- modified the milestones: 3.2.0, 3.3.0 Dec 22, 2023
@coderzc coderzc modified the milestones: 3.3.0, 3.4.0 May 8, 2024
@lhotari lhotari modified the milestones: 4.0.0, 4.1.0 Oct 14, 2024
@coderzc coderzc modified the milestones: 4.1.0, 4.2.0 Sep 1, 2025
@lhotari
Copy link
Member

lhotari commented Nov 4, 2025

Addressed by PIP-234 related #24893. This isn't currently used in the broker, but that could be addressed in another PR if it's really needed.

@lhotari lhotari closed this Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants