Search in sources :

Example 1 with GlobalCommitRequestProto

use of io.seata.serializer.protobuf.generated.GlobalCommitRequestProto in project seata by seata.

the class GlobalCommitRequestConvertor method convert2Proto.

@Override
public GlobalCommitRequestProto convert2Proto(GlobalCommitRequest globalCommitRequest) {
    final short typeCode = globalCommitRequest.getTypeCode();
    final AbstractMessageProto abstractMessage = AbstractMessageProto.newBuilder().setMessageType(MessageTypeProto.forNumber(typeCode)).build();
    final AbstractTransactionRequestProto abstractTransactionRequestProto = AbstractTransactionRequestProto.newBuilder().setAbstractMessage(abstractMessage).build();
    final String extraData = globalCommitRequest.getExtraData();
    AbstractGlobalEndRequestProto abstractGlobalEndRequestProto = AbstractGlobalEndRequestProto.newBuilder().setAbstractTransactionRequest(abstractTransactionRequestProto).setXid(globalCommitRequest.getXid()).setExtraData(extraData == null ? "" : extraData).build();
    GlobalCommitRequestProto result = GlobalCommitRequestProto.newBuilder().setAbstractGlobalEndRequest(abstractGlobalEndRequestProto).build();
    return result;
}
Also used : GlobalCommitRequestProto(io.seata.serializer.protobuf.generated.GlobalCommitRequestProto) AbstractGlobalEndRequestProto(io.seata.serializer.protobuf.generated.AbstractGlobalEndRequestProto) AbstractMessageProto(io.seata.serializer.protobuf.generated.AbstractMessageProto) AbstractTransactionRequestProto(io.seata.serializer.protobuf.generated.AbstractTransactionRequestProto)

Example 2 with GlobalCommitRequestProto

use of io.seata.serializer.protobuf.generated.GlobalCommitRequestProto in project seata by seata.

the class GlobalCommitRequestConvertorTest method convert2Proto.

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

Aggregations

GlobalCommitRequestProto (io.seata.serializer.protobuf.generated.GlobalCommitRequestProto)2 GlobalCommitRequest (io.seata.core.protocol.transaction.GlobalCommitRequest)1 AbstractGlobalEndRequestProto (io.seata.serializer.protobuf.generated.AbstractGlobalEndRequestProto)1 AbstractMessageProto (io.seata.serializer.protobuf.generated.AbstractMessageProto)1 AbstractTransactionRequestProto (io.seata.serializer.protobuf.generated.AbstractTransactionRequestProto)1 Test (org.junit.jupiter.api.Test)1