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