Search in sources :

Example 1 with GlobalStatusRequest

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

the class GlobalStatusRequestConvertorTest method convert2Proto.

@Test
public void convert2Proto() {
    GlobalStatusRequest globalStatusRequest = new GlobalStatusRequest();
    globalStatusRequest.setExtraData("extraData");
    globalStatusRequest.setXid("xid");
    GlobalStatusRequestConvertor convertor = new GlobalStatusRequestConvertor();
    GlobalStatusRequestProto proto = convertor.convert2Proto(globalStatusRequest);
    GlobalStatusRequest real = convertor.convert2Model(proto);
    assertThat((real.getTypeCode())).isEqualTo(globalStatusRequest.getTypeCode());
    assertThat((real.getXid())).isEqualTo(globalStatusRequest.getXid());
    assertThat((real.getExtraData())).isEqualTo(globalStatusRequest.getExtraData());
}
Also used : GlobalStatusRequestProto(io.seata.serializer.protobuf.generated.GlobalStatusRequestProto) GlobalStatusRequest(io.seata.core.protocol.transaction.GlobalStatusRequest) Test(org.junit.jupiter.api.Test)

Example 2 with GlobalStatusRequest

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

the class GlobalStatusRequestConvertor method convert2Model.

@Override
public GlobalStatusRequest convert2Model(GlobalStatusRequestProto globalStatusRequestProto) {
    GlobalStatusRequest branchCommitRequest = new GlobalStatusRequest();
    branchCommitRequest.setExtraData(globalStatusRequestProto.getAbstractGlobalEndRequest().getExtraData());
    branchCommitRequest.setXid(globalStatusRequestProto.getAbstractGlobalEndRequest().getXid());
    return branchCommitRequest;
}
Also used : GlobalStatusRequest(io.seata.core.protocol.transaction.GlobalStatusRequest)

Example 3 with GlobalStatusRequest

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

the class DefaultTransactionManager method getStatus.

@Override
public GlobalStatus getStatus(String xid) throws TransactionException {
    GlobalStatusRequest queryGlobalStatus = new GlobalStatusRequest();
    queryGlobalStatus.setXid(xid);
    GlobalStatusResponse response = (GlobalStatusResponse) syncCall(queryGlobalStatus);
    return response.getGlobalStatus();
}
Also used : GlobalStatusRequest(io.seata.core.protocol.transaction.GlobalStatusRequest) GlobalStatusResponse(io.seata.core.protocol.transaction.GlobalStatusResponse)

Example 4 with GlobalStatusRequest

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

the class GlobalStatusRequestCodecTest method test_codec.

/**
 * Test codec.
 */
@Test
public void test_codec() {
    GlobalStatusRequest globalStatusRequest = new GlobalStatusRequest();
    globalStatusRequest.setExtraData("aaaa");
    globalStatusRequest.setXid("aaa123");
    byte[] bytes = seataSerializer.serialize(globalStatusRequest);
    GlobalStatusRequest globalStatusRequest2 = seataSerializer.deserialize(bytes);
    assertThat(globalStatusRequest2.getExtraData()).isEqualTo(globalStatusRequest.getExtraData());
    assertThat(globalStatusRequest2.getXid()).isEqualTo(globalStatusRequest.getXid());
}
Also used : GlobalStatusRequest(io.seata.core.protocol.transaction.GlobalStatusRequest) Test(org.junit.jupiter.api.Test)

Example 5 with GlobalStatusRequest

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

the class AbstractTCInboundHandler method handle.

@Override
public GlobalStatusResponse handle(GlobalStatusRequest request, final RpcContext rpcContext) {
    GlobalStatusResponse response = new GlobalStatusResponse();
    response.setGlobalStatus(GlobalStatus.UnKnown);
    exceptionHandleTemplate(new AbstractCallback<GlobalStatusRequest, GlobalStatusResponse>() {

        @Override
        public void execute(GlobalStatusRequest request, GlobalStatusResponse response) throws TransactionException {
            try {
                doGlobalStatus(request, response, rpcContext);
            } catch (StoreException e) {
                throw new TransactionException(TransactionExceptionCode.FailedStore, String.format("global status request failed. xid=%s, msg=%s", request.getXid(), e.getMessage()), e);
            }
        }

        @Override
        public void onTransactionException(GlobalStatusRequest request, GlobalStatusResponse response, TransactionException tex) {
            super.onTransactionException(request, response, tex);
            checkTransactionStatus(request, response);
        }

        @Override
        public void onException(GlobalStatusRequest request, GlobalStatusResponse response, Exception rex) {
            super.onException(request, response, rex);
            checkTransactionStatus(request, response);
        }
    }, request, response);
    return response;
}
Also used : TransactionException(io.seata.core.exception.TransactionException) GlobalStatusRequest(io.seata.core.protocol.transaction.GlobalStatusRequest) TransactionException(io.seata.core.exception.TransactionException) StoreException(io.seata.common.exception.StoreException) GlobalStatusResponse(io.seata.core.protocol.transaction.GlobalStatusResponse) StoreException(io.seata.common.exception.StoreException)

Aggregations

GlobalStatusRequest (io.seata.core.protocol.transaction.GlobalStatusRequest)5 GlobalStatusResponse (io.seata.core.protocol.transaction.GlobalStatusResponse)2 Test (org.junit.jupiter.api.Test)2 StoreException (io.seata.common.exception.StoreException)1 TransactionException (io.seata.core.exception.TransactionException)1 GlobalStatusRequestProto (io.seata.serializer.protobuf.generated.GlobalStatusRequestProto)1