Search in sources :

Example 11 with BranchCommitRequest

use of io.seata.core.protocol.transaction.BranchCommitRequest in project seata by seata.

the class AbstractRMHandler method handle.

@Override
public BranchCommitResponse handle(BranchCommitRequest request) {
    BranchCommitResponse response = new BranchCommitResponse();
    exceptionHandleTemplate(new AbstractCallback<BranchCommitRequest, BranchCommitResponse>() {

        @Override
        public void execute(BranchCommitRequest request, BranchCommitResponse response) throws TransactionException {
            doBranchCommit(request, response);
        }
    }, request, response);
    return response;
}
Also used : BranchCommitResponse(io.seata.core.protocol.transaction.BranchCommitResponse) TransactionException(io.seata.core.exception.TransactionException) BranchCommitRequest(io.seata.core.protocol.transaction.BranchCommitRequest)

Example 12 with BranchCommitRequest

use of io.seata.core.protocol.transaction.BranchCommitRequest in project XHuiCloud by sindaZeng.

the class AbstractCore method branchCommit.

@Override
public BranchStatus branchCommit(GlobalSession globalSession, BranchSession branchSession) throws TransactionException {
    try {
        BranchCommitRequest request = new BranchCommitRequest();
        request.setXid(branchSession.getXid());
        request.setBranchId(branchSession.getBranchId());
        request.setResourceId(branchSession.getResourceId());
        request.setApplicationData(branchSession.getApplicationData());
        request.setBranchType(branchSession.getBranchType());
        return branchCommitSend(request, globalSession, branchSession);
    } catch (IOException | TimeoutException e) {
        throw new BranchTransactionException(FailedToSendBranchCommitRequest, String.format("Send branch commit failed, xid = %s branchId = %s", branchSession.getXid(), branchSession.getBranchId()), e);
    }
}
Also used : IOException(java.io.IOException) BranchCommitRequest(io.seata.core.protocol.transaction.BranchCommitRequest) BranchTransactionException(io.seata.core.exception.BranchTransactionException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

BranchCommitRequest (io.seata.core.protocol.transaction.BranchCommitRequest)12 Test (org.junit.jupiter.api.Test)7 NamedThreadFactory (io.seata.common.thread.NamedThreadFactory)2 BranchTransactionException (io.seata.core.exception.BranchTransactionException)2 RpcMessage (io.seata.core.protocol.RpcMessage)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Future (java.util.concurrent.Future)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 TimeoutException (java.util.concurrent.TimeoutException)2 ChannelFuture (io.netty.channel.ChannelFuture)1 TransactionException (io.seata.core.exception.TransactionException)1 FailedToSendBranchCommitRequest (io.seata.core.exception.TransactionExceptionCode.FailedToSendBranchCommitRequest)1 BranchCommitResponse (io.seata.core.protocol.transaction.BranchCommitResponse)1 BranchCommitRequestProto (io.seata.serializer.protobuf.generated.BranchCommitRequestProto)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1