codelipenghui commented on a change in pull request #5680:
[transaction-coordinator] Implementation of transaction coordinator client.
URL: https://github.com/apache/pulsar/pull/5680#discussion_r348869994
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -1399,6 +1402,84 @@ protected void
handleGetOrCreateSchema(CommandGetOrCreateSchema commandGetOrCrea
});
}
+ @Override
+ protected void handleNewTxn(CommandNewTxn command) {
+ if (log.isDebugEnabled()) {
+ log.debug("Receive new txn request {} to transaction meta store {}
from {}.", command.getRequestId(), command.getTcId(), remoteAddress);
+ }
+
service.pulsar().getTransactionMetadataStoreService().newTransaction(TransactionCoordinatorID.get(command.getTcId()))
+ .whenComplete(((txnID, ex) -> {
+ if (ex == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Send response {} for new txn request {}",
command.getTcId(), command.getRequestId());
+ }
+
ctx.writeAndFlush(Commands.newTxnResponse(command.getRequestId(),
txnID.getLeastSigBits(), txnID.getMostSigBits()));
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Send response error for new txn request
{}", command.getRequestId(), ex);
+ }
+
ctx.writeAndFlush(Commands.newTxnResponse(command.getRequestId(),
txnID.getMostSigBits(), BrokerServiceException.getClientErrorCode(ex),
ex.getMessage()));
Review comment:
Oh, can't use txnID.getMostSigBits() here because exception occur, so we
don't have the response txnID from meta store, i will change it
command.getTcId().
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services