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());
}
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;
}
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();
}
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());
}
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;
}
Aggregations