Search in sources :

Example 6 with GlobalCommitResponse

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

the class DefaultTransactionManager method commit.

@Override
public GlobalStatus commit(String xid) throws TransactionException {
    GlobalCommitRequest globalCommit = new GlobalCommitRequest();
    globalCommit.setXid(xid);
    GlobalCommitResponse response = (GlobalCommitResponse) syncCall(globalCommit);
    return response.getGlobalStatus();
}
Also used : GlobalCommitRequest(io.seata.core.protocol.transaction.GlobalCommitRequest) GlobalCommitResponse(io.seata.core.protocol.transaction.GlobalCommitResponse)

Example 7 with GlobalCommitResponse

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

the class GlobalCommitResponseConvertor method convert2Model.

@Override
public GlobalCommitResponse convert2Model(GlobalCommitResponseProto globalCommitResponseProto) {
    GlobalCommitResponse branchRegisterResponse = new GlobalCommitResponse();
    final AbstractGlobalEndResponseProto abstractGlobalEndResponse = globalCommitResponseProto.getAbstractGlobalEndResponse();
    AbstractTransactionResponseProto abstractResultMessage = abstractGlobalEndResponse.getAbstractTransactionResponse();
    branchRegisterResponse.setMsg(abstractResultMessage.getAbstractResultMessage().getMsg());
    branchRegisterResponse.setResultCode(ResultCode.valueOf(abstractResultMessage.getAbstractResultMessage().getResultCode().name()));
    branchRegisterResponse.setTransactionExceptionCode(TransactionExceptionCode.valueOf(abstractResultMessage.getTransactionExceptionCode().name()));
    branchRegisterResponse.setGlobalStatus(GlobalStatus.valueOf(abstractGlobalEndResponse.getGlobalStatus().name()));
    return branchRegisterResponse;
}
Also used : AbstractGlobalEndResponseProto(io.seata.serializer.protobuf.generated.AbstractGlobalEndResponseProto) GlobalCommitResponse(io.seata.core.protocol.transaction.GlobalCommitResponse) AbstractTransactionResponseProto(io.seata.serializer.protobuf.generated.AbstractTransactionResponseProto)

Example 8 with GlobalCommitResponse

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

the class GlobalCommitResponseTest method testToString.

/**
 * Test to string.
 *
 * @throws Exception the exception
 */
@Test
public void testToString() throws Exception {
    GlobalCommitResponse globalCommitResponse = new GlobalCommitResponse();
    globalCommitResponse.setGlobalStatus(GlobalStatus.Committed);
    globalCommitResponse.setResultCode(ResultCode.Success);
    globalCommitResponse.setMsg("OK");
    System.out.println(globalCommitResponse.toString());
    Assertions.assertEquals("globalStatus=Committed,ResultCode=Success,Msg=OK", globalCommitResponse.toString());
}
Also used : GlobalCommitResponse(io.seata.core.protocol.transaction.GlobalCommitResponse) Test(org.junit.jupiter.api.Test)

Aggregations

GlobalCommitResponse (io.seata.core.protocol.transaction.GlobalCommitResponse)8 Test (org.junit.jupiter.api.Test)5 GlobalCommitRequest (io.seata.core.protocol.transaction.GlobalCommitRequest)3 StoreException (io.seata.common.exception.StoreException)1 TransactionException (io.seata.core.exception.TransactionException)1 AbstractResultMessage (io.seata.core.protocol.AbstractResultMessage)1 MergeResultMessage (io.seata.core.protocol.MergeResultMessage)1 GlobalBeginRequest (io.seata.core.protocol.transaction.GlobalBeginRequest)1 GlobalBeginResponse (io.seata.core.protocol.transaction.GlobalBeginResponse)1 GlobalRollbackRequest (io.seata.core.protocol.transaction.GlobalRollbackRequest)1 GlobalRollbackResponse (io.seata.core.protocol.transaction.GlobalRollbackResponse)1 RpcContext (io.seata.core.rpc.RpcContext)1 Measurement (io.seata.metrics.Measurement)1 AbstractGlobalEndResponseProto (io.seata.serializer.protobuf.generated.AbstractGlobalEndResponseProto)1 AbstractTransactionResponseProto (io.seata.serializer.protobuf.generated.AbstractTransactionResponseProto)1 GlobalCommitResponseProto (io.seata.serializer.protobuf.generated.GlobalCommitResponseProto)1 MergedResultMessageProto (io.seata.serializer.protobuf.generated.MergedResultMessageProto)1 MockServerMessageSender (io.seata.server.coordinator.DefaultCoordinatorTest.MockServerMessageSender)1 HashMap (java.util.HashMap)1