Skip to content

Conversation

@ConeyLiu
Copy link

@ConeyLiu ConeyLiu commented Sep 18, 2018

What is the purpose of the change

We have already stated in the documentation that the version of the JDK requirement is 1.8. So we should update the JDK dependency to JDK1.8.

Brief changelog

  • Upgrade the JDK dependency.

  • Code clean based on the new features of ConcurrentHashMap in JDK 1.8.

Verifying this change

Existing UT test.

Follow this checklist to help us incorporate your contribution quickly and easily. Notice, it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR.

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

if (createNew) {
// Internal class requires final variables
final AtomicBoolean createNew = new AtomicBoolean(false);
TopicConfig topicConfig = this.topicConfigTable.computeIfAbsent(topic, key -> {
Copy link
Author

Choose a reason for hiding this comment

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

Avoid lock contention of lockTopicConfigTable.

Copy link
Member

Choose a reason for hiding this comment

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

@ConeyLiu why you polish createTopicInSendMessageBackMethod and skip createTopicInSendMessageMethod?

Copy link
Author

Choose a reason for hiding this comment

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

Hi, @dongeforever. The lockTopicConfigTable is a global lock which can reduce the performance of ConcurrentHashMap. The computIfAbsent of ConcurrentHashMap can provide an atomic operation with better performance. This is should be an improvement.

if (null == preConfig) {
log.info("auto create a subscription group, {}", subscriptionGroupConfig.toString());
}
subscriptionGroupConfig = this.subscriptionGroupTable.computeIfAbsent(group, (key) -> {
Copy link
Author

Choose a reason for hiding this comment

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

The function is only called when the value is absent. So this can avoid unnecessary object creation.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 42.446% when pulling d68b71f on ConeyLiu:codeclean into a220364 on apache:master.

@dongeforever
Copy link
Member

@ConeyLiu The client need to be compatible with 1.6. And I remember their is a compatible problem in ConcurrentHashMap, it will throw exception in 1.6 if its source is built in 1.8.
I will have a check when I am available next time.

@ConeyLiu
Copy link
Author

ConeyLiu commented Sep 25, 2018

@dongeforever, thanks for the review. I only upgrade the JDK dependency of server-side. And also the test is passed, seems shouldn't any compatible problem.

@dongeforever
Copy link
Member

@ConeyLiu Yeah,I have found the old pr https://github.com/apache/rocketmq/pull/110。
It has nothing to do with JDK 1.8.

@dongeforever
Copy link
Member

@ConeyLiu It seems ok to upgrade jdk to 1.8 in server side. But the community version may not upgrade it until it is sure.

@ConeyLiu
Copy link
Author

OK, thanks @dongeforever. It's OK to pending here if there is any concern. I'd like to contribute more to the RocketMQ.

@vongosling vongosling force-pushed the master branch 2 times, most recently from 247e0bf to ce4478a Compare October 12, 2019 06:44
@ShannonDing
Copy link
Member

it seems too long and conflicts exist for this PR, I will close it for time being. for any issues, welcome to create new PR to the develop branch.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants