Search in sources :

Example 1 with GlobalLockQueryResponse

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;
}
Also used : TransactionException(io.seata.core.exception.TransactionException) GlobalLockQueryRequest(io.seata.core.protocol.transaction.GlobalLockQueryRequest) GlobalLockQueryResponse(io.seata.core.protocol.transaction.GlobalLockQueryResponse) StoreException(io.seata.common.exception.StoreException)

Example 2 with GlobalLockQueryResponse

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;
}
Also used : AbstractResultMessageProto(io.seata.serializer.protobuf.generated.AbstractResultMessageProto) AbstractTransactionResponseProto(io.seata.serializer.protobuf.generated.AbstractTransactionResponseProto) GlobalLockQueryResponse(io.seata.core.protocol.transaction.GlobalLockQueryResponse)

Example 3 with GlobalLockQueryResponse

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);
}
Also used : GlobalLockQueryResponse(io.seata.core.protocol.transaction.GlobalLockQueryResponse)

Example 4 with GlobalLockQueryResponse

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());
}
Also used : GlobalLockQueryResponse(io.seata.core.protocol.transaction.GlobalLockQueryResponse) Test(org.junit.jupiter.api.Test)

Example 5 with GlobalLockQueryResponse

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));
}
Also used : GlobalLockQueryResponse(io.seata.core.protocol.transaction.GlobalLockQueryResponse)

Aggregations

GlobalLockQueryResponse (io.seata.core.protocol.transaction.GlobalLockQueryResponse)7 TransactionException (io.seata.core.exception.TransactionException)2 GlobalLockQueryRequest (io.seata.core.protocol.transaction.GlobalLockQueryRequest)2 Test (org.junit.jupiter.api.Test)2 StoreException (io.seata.common.exception.StoreException)1 RmTransactionException (io.seata.core.exception.RmTransactionException)1 AbstractResultMessageProto (io.seata.serializer.protobuf.generated.AbstractResultMessageProto)1 AbstractTransactionResponseProto (io.seata.serializer.protobuf.generated.AbstractTransactionResponseProto)1 GlobalLockQueryResponseProto (io.seata.serializer.protobuf.generated.GlobalLockQueryResponseProto)1 TimeoutException (java.util.concurrent.TimeoutException)1