You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/11/21 02:27:32 UTC

[GitHub] [pulsar] codelipenghui commented on a change in pull request #5680: [transaction-coordinator] Implementation of transaction coordinator client.

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, i here can't use txnID.getMostSigBits(), because exception occur here, 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:
users@infra.apache.org


With regards,
Apache Git Services