Search in sources :

Example 1 with RegisterTMRequest

use of io.seata.core.protocol.RegisterTMRequest in project seata by seata.

the class TmNettyRemotingClient method onRegisterMsgFail.

@Override
public void onRegisterMsgFail(String serverAddress, Channel channel, Object response, AbstractMessage requestMessage) {
    RegisterTMRequest registerTMRequest = (RegisterTMRequest) requestMessage;
    RegisterTMResponse registerTMResponse = (RegisterTMResponse) response;
    String errMsg = String.format("register TM failed. client version: %s,server version: %s, errorMsg: %s, " + "channel: %s", registerTMRequest.getVersion(), registerTMResponse.getVersion(), registerTMResponse.getMsg(), channel);
    throw new FrameworkException(errMsg);
}
Also used : RegisterTMResponse(io.seata.core.protocol.RegisterTMResponse) FrameworkException(io.seata.common.exception.FrameworkException) RegisterTMRequest(io.seata.core.protocol.RegisterTMRequest)

Example 2 with RegisterTMRequest

use of io.seata.core.protocol.RegisterTMRequest in project seata by seata.

the class RegTmProcessor method onRegTmMessage.

private void onRegTmMessage(ChannelHandlerContext ctx, RpcMessage rpcMessage) {
    RegisterTMRequest message = (RegisterTMRequest) rpcMessage.getBody();
    String ipAndPort = NetUtil.toStringAddress(ctx.channel().remoteAddress());
    Version.putChannelVersion(ctx.channel(), message.getVersion());
    boolean isSuccess = false;
    String errorInfo = StringUtils.EMPTY;
    try {
        if (null == checkAuthHandler || checkAuthHandler.regTransactionManagerCheckAuth(message)) {
            ChannelManager.registerTMChannel(message, ctx.channel());
            Version.putChannelVersion(ctx.channel(), message.getVersion());
            isSuccess = true;
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("checkAuth for client:{},vgroup:{},applicationId:{}", ipAndPort, message.getTransactionServiceGroup(), message.getApplicationId());
            }
        }
    } catch (Exception exx) {
        isSuccess = false;
        errorInfo = exx.getMessage();
        LOGGER.error("TM register fail, error message:{}", errorInfo);
    }
    RegisterTMResponse response = new RegisterTMResponse(isSuccess);
    if (StringUtils.isNotEmpty(errorInfo)) {
        response.setMsg(errorInfo);
    }
    remotingServer.sendAsyncResponse(rpcMessage, ctx.channel(), response);
    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("TM register success,message:{},channel:{},client version:{}", message, ctx.channel(), message.getVersion());
    }
}
Also used : RegisterTMResponse(io.seata.core.protocol.RegisterTMResponse) RegisterTMRequest(io.seata.core.protocol.RegisterTMRequest)

Example 3 with RegisterTMRequest

use of io.seata.core.protocol.RegisterTMRequest in project seata by seata.

the class RegisterTMRequestTest method testToString.

/**
 * Test to string.
 *
 * @throws Exception the exception
 */
@Test
public void testToString() throws Exception {
    RegisterTMRequest registerTMRequest = new RegisterTMRequest();
    registerTMRequest.setApplicationId("seata");
    registerTMRequest.setTransactionServiceGroup("daliy_2019");
    registerTMRequest.setVersion("2019-snapshot");
    Assertions.assertEquals("RegisterTMRequest{applicationId='seata', transactionServiceGroup='daliy_2019'}", registerTMRequest.toString());
}
Also used : RegisterTMRequest(io.seata.core.protocol.RegisterTMRequest) Test(org.junit.jupiter.api.Test)

Example 4 with RegisterTMRequest

use of io.seata.core.protocol.RegisterTMRequest in project seata by seata.

the class RegisterTMRequestSerializerTest method setupNull.

/**
 * Constructor without arguments
 */
@BeforeAll
public static void setupNull() {
    registerTMRequest = new RegisterTMRequest();
    air = Mockito.mock(AbstractIdentifyRequest.class, Mockito.CALLS_REAL_METHODS);
}
Also used : RegisterTMRequest(io.seata.core.protocol.RegisterTMRequest) AbstractIdentifyRequest(io.seata.core.protocol.AbstractIdentifyRequest) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with RegisterTMRequest

use of io.seata.core.protocol.RegisterTMRequest in project seata by seata.

the class RegisterTMRequestSerializerTest method setupWithValues.

/**
 * Constructor with arguments
 */
@BeforeAll
public static void setupWithValues() {
    registerTMRequest = new RegisterTMRequest(APP_ID, TSG, ED);
    air = Mockito.mock(AbstractIdentifyRequest.class, Mockito.CALLS_REAL_METHODS);
}
Also used : RegisterTMRequest(io.seata.core.protocol.RegisterTMRequest) AbstractIdentifyRequest(io.seata.core.protocol.AbstractIdentifyRequest) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

RegisterTMRequest (io.seata.core.protocol.RegisterTMRequest)10 RegisterTMResponse (io.seata.core.protocol.RegisterTMResponse)4 Test (org.junit.jupiter.api.Test)3 AbstractIdentifyRequest (io.seata.core.protocol.AbstractIdentifyRequest)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 FrameworkException (io.seata.common.exception.FrameworkException)1 AbstractIdentifyRequestProto (io.seata.serializer.protobuf.generated.AbstractIdentifyRequestProto)1 RegisterTMRequestProto (io.seata.serializer.protobuf.generated.RegisterTMRequestProto)1