Skip to content

[improve][txn]Clean up redundant logic in transaction client#19345

Merged
Technoboy- merged 1 commit intoapache:masterfrom
liangyepianzhou:xiangying/txn/op/clientCleanUp-1
Jan 29, 2023
Merged

[improve][txn]Clean up redundant logic in transaction client#19345
Technoboy- merged 1 commit intoapache:masterfrom
liangyepianzhou:xiangying/txn/op/clientCleanUp-1

Conversation

@liangyepianzhou
Copy link
Contributor

@liangyepianzhou liangyepianzhou commented Jan 28, 2023

Motivation

The parameter i passed to getTCAssignTopicName cannot be lower than 0.
Therefore, the method getTCAssignTopicName does not need to consider the partition < 0.

if (partitionMeta.partitions > 0) {
handlers = new TransactionMetaStoreHandler[partitionMeta.partitions];
for (int i = 0; i < partitionMeta.partitions; i++) {
CompletableFuture<Void> connectFuture = new CompletableFuture<>();
connectFutureList.add(connectFuture);
TransactionMetaStoreHandler handler = new TransactionMetaStoreHandler(
i, pulsarClient, getTCAssignTopicName(i), connectFuture);
handlers[i] = handler;
handlerMap.put(i, handler);
handler.start();
}
} else {
return FutureUtil.failedFuture(new TransactionCoordinatorClientException(
"The broker doesn't enable the transaction coordinator, "
+ "or the transaction coordinator has not initialized"));
}
STATE_UPDATER.set(TransactionCoordinatorClientImpl.this, State.READY);
return FutureUtil.waitForAll(connectFutureList);
});

private String getTCAssignTopicName(int partition) {
if (partition >= 0) {
return SystemTopicNames.TRANSACTION_COORDINATOR_ASSIGN.toString()
+ TopicName.PARTITIONED_TOPIC_SUFFIX + partition;
} else {
return SystemTopicNames.TRANSACTION_COORDINATOR_ASSIGN.toString();
}
}

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

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

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jan 28, 2023
@Technoboy- Technoboy- added this to the 2.12.0 milestone Jan 29, 2023
@Technoboy- Technoboy- closed this Jan 29, 2023
@Technoboy- Technoboy- reopened this Jan 29, 2023
Copy link
Member

@mattisonchao mattisonchao left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-commenter
Copy link

Codecov Report

Merging #19345 (4bc6de1) into master (fcecca4) will increase coverage by 30.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #19345       +/-   ##
=============================================
+ Coverage     32.45%   62.52%   +30.06%     
- Complexity     6348    25428    +19080     
=============================================
  Files          1644     1818      +174     
  Lines        123737   133107     +9370     
  Branches      13494    14644     +1150     
=============================================
+ Hits          40162    83225    +43063     
+ Misses        77654    42195    -35459     
- Partials       5921     7687     +1766     
Flag Coverage Δ
inttests 24.97% <100.00%> (+0.01%) ⬆️
systests 25.57% <66.66%> (-0.10%) ⬇️
unittests 59.64% <100.00%> (+42.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...pache/pulsar/broker/admin/v2/PersistentTopics.java 75.23% <ø> (+65.60%) ⬆️
...in/java/org/apache/pulsar/admin/cli/CmdTopics.java 80.16% <ø> (+80.16%) ⬆️
...mon/policies/data/stats/SubscriptionStatsImpl.java 74.74% <ø> (+32.32%) ⬆️
...rg/apache/bookkeeper/mledger/impl/OpReadEntry.java 72.44% <100.00%> (+5.43%) ⬆️
...ker/service/persistent/PersistentSubscription.java 68.16% <100.00%> (+21.79%) ⬆️
.../transaction/TransactionCoordinatorClientImpl.java 53.15% <100.00%> (+5.36%) ⬆️
...in/java/org/apache/pulsar/common/api/AuthData.java 71.42% <0.00%> (ø)
...a/org/apache/pulsar/client/impl/RawReaderImpl.java 82.69% <0.00%> (ø)
...ava/org/apache/pulsar/client/api/schema/Field.java 80.00% <0.00%> (ø)
.../apache/pulsar/broker/namespace/LookupOptions.java 87.50% <0.00%> (ø)
... and 1187 more

@Technoboy- Technoboy- merged commit c17f355 into apache:master Jan 29, 2023
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 ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants