Search in sources :

Example 1 with FrameworkException

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);
}
Also used : RegisterTMResponse(io.seata.core.protocol.RegisterTMResponse) FrameworkException(io.seata.common.exception.FrameworkException) RegisterTMRequest(io.seata.core.protocol.RegisterTMRequest)

Example 2 with FrameworkException

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);
    }
}
Also used : FrameworkException(io.seata.common.exception.FrameworkException) RemotingDesc(io.seata.rm.tcc.remoting.RemotingDesc)

Example 3 with FrameworkException

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;
}
Also used : FrameworkException(io.seata.common.exception.FrameworkException) Channel(io.netty.channel.Channel) RegisterRMRequest(io.seata.core.protocol.RegisterRMRequest) FrameworkException(io.seata.common.exception.FrameworkException)

Example 4 with FrameworkException

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);
}
Also used : FrameworkException(io.seata.common.exception.FrameworkException) RegisterRMResponse(io.seata.core.protocol.RegisterRMResponse) RegisterRMRequest(io.seata.core.protocol.RegisterRMRequest)

Example 5 with FrameworkException

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);
        }
    }
}
Also used : FrameworkException(io.seata.common.exception.FrameworkException) RegisterRMRequest(io.seata.core.protocol.RegisterRMRequest)

Aggregations

FrameworkException (io.seata.common.exception.FrameworkException)26 Channel (io.netty.channel.Channel)5 RemotingDesc (io.seata.rm.tcc.remoting.RemotingDesc)5 HashMap (java.util.HashMap)5 RegisterRMRequest (io.seata.core.protocol.RegisterRMRequest)3 List (java.util.List)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 ConcurrentSet (io.netty.util.internal.ConcurrentSet)2 FrameworkErrorCode (io.seata.common.exception.FrameworkErrorCode)2 TransactionException (io.seata.core.exception.TransactionException)2 RowLock (io.seata.core.lock.RowLock)2 ProcessType (io.seata.saga.proctrl.ProcessType)2 State (io.seata.saga.statelang.domain.State)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Set (java.util.Set)2 ChannelFuture (io.netty.channel.ChannelFuture)1 ChannelFutureListener (io.netty.channel.ChannelFutureListener)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 SocketChannel (io.netty.channel.socket.SocketChannel)1