@Override
    public Connection createConnection(String targetIP, int targetPort, byte version,
                                       int connectTimeout) throws Exception {
        Channel channel = doCreateConnection(targetIP, targetPort, connectTimeout);
        Connection conn = new Connection(channel,
            ProtocolCode.fromBytes(RpcProtocolV2.PROTOCOL_CODE), version, new Url(targetIP,
                targetPort));
        if (channel.isActive()) {
            channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT);
        } else {
            channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT_FAILED);
            throw new RemotingException(
                "create connection, but channel is inactive, target address is " + targetIP + ":"
                        + targetPort);
        }
        return conn;
    }
ConnectionFactory to create connection.

@author chengyi (mark.lx@antfin.com) 2018-06-20 14:29
src/main/java/com/alipay/remoting/connection/AbstractConnectionFactory.java