use of io.seata.core.protocol.transaction.GlobalLockQueryResponse in project seata by seata.
the class AbstractTCInboundHandler method handle.
@Override
public GlobalLockQueryResponse handle(GlobalLockQueryRequest request, final RpcContext rpcContext) {
GlobalLockQueryResponse response = new GlobalLockQueryResponse();
exceptionHandleTemplate(new AbstractCallback<GlobalLockQueryRequest, GlobalLockQueryResponse>() {
@Override
public void execute(GlobalLockQueryRequest request, GlobalLockQueryResponse response) throws TransactionException {
try {
doLockCheck(request, response, rpcContext);
} catch (StoreException e) {
throw new TransactionException(TransactionExceptionCode.FailedStore, String.format("global lock query request failed. xid=%s, msg=%s", request.getXid(), e.getMessage()), e);
}
}
}, request, response);
return response;
}
use of io.seata.core.protocol.transaction.GlobalLockQueryResponse in project seata by seata.
the class GlobalLockQueryResponseConvertor method convert2Model.
@Override
public GlobalLockQueryResponse convert2Model(GlobalLockQueryResponseProto globalLockQueryResponseProto) {
GlobalLockQueryResponse branchRegisterResponse = new GlobalLockQueryResponse();
AbstractTransactionResponseProto branchRegisterResponseProto = globalLockQueryResponseProto.getAbstractTransactionResponse();
final AbstractResultMessageProto abstractResultMessage = branchRegisterResponseProto.getAbstractResultMessage();
branchRegisterResponse.setMsg(abstractResultMessage.getMsg());
branchRegisterResponse.setResultCode(ResultCode.valueOf(abstractResultMessage.getResultCode().name()));
branchRegisterResponse.setTransactionExceptionCode(TransactionExceptionCode.valueOf(branchRegisterResponseProto.getTransactionExceptionCode().name()));
branchRegisterResponse.setLockable(globalLockQueryResponseProto.getLockable());
return branchRegisterResponse;
}
use of io.seata.core.protocol.transaction.GlobalLockQueryResponse in project seata by seata.
the class GlobalLockQueryResponseCodec method decode.
@Override
public <T> void decode(T t, ByteBuffer in) {
super.decode(t, in);
GlobalLockQueryResponse globalLockQueryResponse = (GlobalLockQueryResponse) t;
globalLockQueryResponse.setLockable(in.getShort() == 1);
}
use of io.seata.core.protocol.transaction.GlobalLockQueryResponse in project seata by seata.
the class GlobalLockQueryResponseSerializerTest method test_codec.
/**
* Test codec.
*/
@Test
public void test_codec() {
GlobalLockQueryResponse globalLockQueryResponse = new GlobalLockQueryResponse();
globalLockQueryResponse.setLockable(true);
globalLockQueryResponse.setMsg("aa");
globalLockQueryResponse.setResultCode(ResultCode.Failed);
globalLockQueryResponse.setTransactionExceptionCode(TransactionExceptionCode.GlobalTransactionStatusInvalid);
byte[] bytes = seataSerializer.serialize(globalLockQueryResponse);
GlobalLockQueryResponse globalLockQueryResponse2 = seataSerializer.deserialize(bytes);
assertThat(globalLockQueryResponse2.isLockable()).isEqualTo(globalLockQueryResponse.isLockable());
assertThat(globalLockQueryResponse2.getResultCode()).isEqualTo(globalLockQueryResponse.getResultCode());
assertThat(globalLockQueryResponse2.getTransactionExceptionCode()).isEqualTo(globalLockQueryResponse.getTransactionExceptionCode());
assertThat(globalLockQueryResponse2.getMsg()).isEqualTo(globalLockQueryResponse.getMsg());
}
use of io.seata.core.protocol.transaction.GlobalLockQueryResponse in project seata by seata.
the class GlobalLockQueryResponseCodec method encode.
@Override
public <T> void encode(T t, ByteBuf out) {
super.encode(t, out);
GlobalLockQueryResponse globalLockQueryResponse = (GlobalLockQueryResponse) t;
boolean lockable = globalLockQueryResponse.isLockable();
out.writeShort((short) (lockable ? 1 : 0));
}
Aggregations