Skip to content

Conversation

@freeznet
Copy link
Contributor

@freeznet freeznet commented May 8, 2021

Fixes #9640
Part 1

Motivation

Module pulsar-client-admin-api has been introduced in #9246, but it pulling in many dependencies.  That is undesirable for an "API" module. As @sijie @merlimat and @jerrypeng suggests, this pr resolves the issue and make pulsar-client-admin-api has minimal transient dependences.

This PR removes pulsar-client-original from the dependency, and resolves the issues. Later there will be sepreate PRs to remove other dependencies like pulsar-common and pulsar-package-core.

I will close #9842 and keep update here.

Modifications

remove pulsar-client-original from pulsar-client-admin-api.

Verifying this change

  • Make sure that the change passes the CI checks.

@freeznet freeznet force-pushed the freeznet/remove-client-admin-api-dependency-pulsar-client-original branch from 2dd33ad to 2ef02f5 Compare May 8, 2021 12:46
@freeznet freeznet changed the title [fix #9640] remove client admin api dependency pulsar client original / part 1 [fix #9640] remove pulsar-client-admin-api dependency : pulsar-client-original May 8, 2021
@freeznet
Copy link
Contributor Author

freeznet commented May 8, 2021

/pulsarbot run-failure-checks

@freeznet freeznet force-pushed the freeznet/remove-client-admin-api-dependency-pulsar-client-original branch from f4601e6 to 13b8f5c Compare May 10, 2021 09:38
@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

@freeznet freeznet force-pushed the freeznet/remove-client-admin-api-dependency-pulsar-client-original branch 2 times, most recently from bf799e3 to 8f45944 Compare May 11, 2021 02:52
@freeznet
Copy link
Contributor Author

@sijie @merlimat @jerrypeng @codelipenghui please help to review this PR if you have time, thanks.


<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>pulsar-client-original</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need pulsar client explicitly for Kafka connector?

Copy link
Contributor Author

@freeznet freeznet May 11, 2021

Choose a reason for hiding this comment

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

@merlimat I believe this is related to the conversion between pulsar's schema and kafka's schema. So kafka connector need pulsar-client-original which all schema impls are in the package.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, @freeznet is right. we need Schema Impl classes

@Override
public void completed(OffloadProcessStatus offloadProcessStatus) {
public void completed(String jsonString) {
Gson gson = new GsonBuilder().registerTypeAdapter(MessageId.class,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use Jackson for all the JSON ser/de, unless there's a particular reason not to do so. Please use ObjectMapperFactory.getThreadLocal()....

Copy link
Contributor Author

@freeznet freeznet May 11, 2021

Choose a reason for hiding this comment

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

Thanks for your suggestion. The reason why I use Gson here is that I noticed TopicsImpl.java is using Gson to de REST response to JsonObject already, like getInternalInfoAsync, so I havent try Jackson here to avoid additional imports.

And in this case, we want de MessageId.class to MessageIdImpl.class, Gson have a simpler way to map interface (MessageId.class) with implementation class (MessageIdImpl.class), for Jackson we cannot use @JsonDeserialize annotation because we dont want to have Jackson dependency in pulsar-client-admin-api, but I have googled with a solution with SimpleAbstractTypeResolver, like

ObjectMapper mapper = ObjectMapperFactory.create();
SimpleModule module = new SimpleModule("OffloadProcessStatusConvertModule",
        Version.unknownVersion());

SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
resolver.addMapping(MessageId.class, MessageIdImpl.class);

module.setAbstractTypes(resolver);
mapper.registerModule(module);

So if we want to use Jackson here, we may try this way.

Also I do confuse with Gson and Jackson here in Pulsar, do we want to replace Gson with Jackson, or we will keep the mixed usage but prefer Jackson by default? And what are the concerns?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

freeznet@fa05e38
here is a sample commit that changes Gson to Jackson.

Copy link
Contributor

Choose a reason for hiding this comment

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

We want to make sure to use Jackson, through the ObjectMapperFactory.getThreadLocal() since it comes configured with some settings.

If @JsonDeserialize annotations are the problem, there will be bigger problems porting the POJOs defined in pulsar-common.

The better option here is to untie the pulsar-client-admin-api from the POJOs. Instead, pulsar-client-admin-api should return Java interfaces instead of POJOs that are used for serialization.

Copy link
Contributor Author

@freeznet freeznet May 12, 2021

Choose a reason for hiding this comment

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

@merlimat Indeed, there will be some problems with pulsar-common. But if we return Java interfaces instead of POJOs, we still need to have a mapping list to have Java Interface -> POJO so that Jackson can do the deserialization.

@merlimat merlimat added the release/blocker Indicate the PR or issue that should block the release until it gets resolved label May 11, 2021
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM


<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>pulsar-client-original</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

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

yes, @freeznet is right. we need Schema Impl classes

@freeznet freeznet force-pushed the freeznet/remove-client-admin-api-dependency-pulsar-client-original branch 2 times, most recently from a1f878f to e5fd1b3 Compare May 12, 2021 08:39
// because we do not want to have jackson dependency in pulsar-client-admin-api
// In this case we use SimpleAbstractTypeResolver to map interfaces to impls
SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
resolver.addMapping(OffloadProcessStatus.class, OffloadProcessStatusImpl.class);
Copy link
Contributor Author

@freeznet freeznet May 12, 2021

Choose a reason for hiding this comment

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

@merlimat I have added a SimpleAbstractTypeResolver here, and will manually map interfaces with impl classes.

@freeznet freeznet force-pushed the freeznet/remove-client-admin-api-dependency-pulsar-client-original branch from e5fd1b3 to 747d7fd Compare May 12, 2021 09:10
@freeznet
Copy link
Contributor Author

freeznet commented May 12, 2021

This PR introduced a new dependency gson to pulsar-client-admin-api, I will remove it in a separate PR.

<artifactId>pulsar-client-original</artifactId>
<version>${project.parent.version}</version>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

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

if gson is not already a dependency imported by pulsar-client-original in 2.7.x I would like to not add it.
Users of pulsar-client-original already have Jackson and usually who uses pulsar-client-admin-api uses pulsar-client, so I would lean toward using only Jackson.

what's your plan for removing gson in a follow up patch ? this next patch will become a blocker for the 2.8 release

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding gson as the dependency is a temporary action, with removal of pulsar-client-original and pulsar-package-core, pulsar-client-admin-api will lose dependency of gson, but we still have a lot of classes import gson, such as

.

I do understand that the 2.8 release is in a hurry, but there are indeed many problems that need to be fixed one by one in order to achieve the ultimate goal. So the removal of gson will be in a separate PR soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

My problem was about "adding" gson, if it was not already there, so to me this is not a problem.

thanks for your clarification

@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM

@freeznet freeznet force-pushed the freeznet/remove-client-admin-api-dependency-pulsar-client-original branch from 747d7fd to 3629c7a Compare May 13, 2021 01:43
@freeznet freeznet force-pushed the freeznet/remove-client-admin-api-dependency-pulsar-client-original branch from 3629c7a to 4a7dc75 Compare May 13, 2021 03:24
@freeznet freeznet closed this May 13, 2021
@freeznet freeznet deleted the freeznet/remove-client-admin-api-dependency-pulsar-client-original branch May 13, 2021 03:35
@freeznet freeznet changed the title [fix #9640] remove pulsar-client-admin-api dependency : pulsar-client-original [trans to #10563][fix #9640] remove pulsar-client-admin-api dependency : pulsar-client-original May 13, 2021
@freeznet
Copy link
Contributor Author

due to my mistaken ops on the branch, this PR has been closed, so please move to #10563, sorry for the inconvenience.

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

Labels

area/build release/blocker Indicate the PR or issue that should block the release until it gets resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pulsar-client-admin-api has excessive transient dependencies

3 participants