use of io.seata.common.exception.FrameworkException 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.common.exception.FrameworkException in project seata by seata.
the class DubboRemotingParser method getServiceDesc.
@Override
public RemotingDesc getServiceDesc(Object bean, String beanName) throws FrameworkException {
if (!this.isRemoting(bean, beanName)) {
return null;
}
try {
RemotingDesc serviceBeanDesc = new RemotingDesc();
Class<?> interfaceClass = (Class<?>) ReflectionUtil.invokeMethod(bean, "getInterfaceClass");
String interfaceClassName = (String) ReflectionUtil.getFieldValue(bean, "interfaceName");
String version = (String) ReflectionUtil.invokeMethod(bean, "getVersion");
String group = (String) ReflectionUtil.invokeMethod(bean, "getGroup");
serviceBeanDesc.setInterfaceClass(interfaceClass);
serviceBeanDesc.setInterfaceClassName(interfaceClassName);
serviceBeanDesc.setUniqueId(version);
serviceBeanDesc.setGroup(group);
serviceBeanDesc.setProtocol(Protocols.DUBBO);
if (isService(bean, beanName)) {
Object targetBean = ReflectionUtil.getFieldValue(bean, "ref");
serviceBeanDesc.setTargetBean(targetBean);
}
return serviceBeanDesc;
} catch (Throwable t) {
throw new FrameworkException(t);
}
}
use of io.seata.common.exception.FrameworkException in project seata by seata.
the class NettyClientChannelManager method doConnect.
private Channel doConnect(String serverAddress) {
Channel channelToServer = channels.get(serverAddress);
if (channelToServer != null && channelToServer.isActive()) {
return channelToServer;
}
Channel channelFromPool;
try {
NettyPoolKey currentPoolKey = poolKeyFunction.apply(serverAddress);
NettyPoolKey previousPoolKey = poolKeyMap.putIfAbsent(serverAddress, currentPoolKey);
if (previousPoolKey != null && previousPoolKey.getMessage() instanceof RegisterRMRequest) {
RegisterRMRequest registerRMRequest = (RegisterRMRequest) currentPoolKey.getMessage();
((RegisterRMRequest) previousPoolKey.getMessage()).setResourceIds(registerRMRequest.getResourceIds());
}
channelFromPool = nettyClientKeyPool.borrowObject(poolKeyMap.get(serverAddress));
channels.put(serverAddress, channelFromPool);
} catch (Exception exx) {
LOGGER.error("{} register RM failed.", FrameworkErrorCode.RegisterRM.getErrCode(), exx);
throw new FrameworkException("can not register RM,err:" + exx.getMessage());
}
return channelFromPool;
}
use of io.seata.common.exception.FrameworkException in project seata by seata.
the class RmNettyRemotingClient method onRegisterMsgFail.
@Override
public void onRegisterMsgFail(String serverAddress, Channel channel, Object response, AbstractMessage requestMessage) {
RegisterRMRequest registerRMRequest = (RegisterRMRequest) requestMessage;
RegisterRMResponse registerRMResponse = (RegisterRMResponse) response;
String errMsg = String.format("register RM failed. client version: %s,server version: %s, errorMsg: %s, " + "channel: %s", registerRMRequest.getVersion(), registerRMResponse.getVersion(), registerRMResponse.getMsg(), channel);
throw new FrameworkException(errMsg);
}
use of io.seata.common.exception.FrameworkException in project seata by seata.
the class RmNettyRemotingClient method sendRegisterMessage.
public void sendRegisterMessage(String serverAddress, Channel channel, String resourceId) {
RegisterRMRequest message = new RegisterRMRequest(applicationId, transactionServiceGroup);
message.setResourceIds(resourceId);
try {
super.sendAsyncRequest(channel, message);
} catch (FrameworkException e) {
if (e.getErrcode() == FrameworkErrorCode.ChannelIsNotWritable && serverAddress != null) {
getClientChannelManager().releaseChannel(channel, serverAddress);
if (LOGGER.isInfoEnabled()) {
LOGGER.info("remove not writable channel:{}", channel);
}
} else {
LOGGER.error("register resource failed, channel:{},resourceId:{}", channel, resourceId, e);
}
}
}
Aggregations