use of io.mycat.proxy.handler.BackendNIOHandler in project Mycat2 by MyCATApache.
the class ProxyReactorThread method processConnectKey.
/**
* 该方法仅Reactor自身创建的主动连接使用
*/
@SuppressWarnings("unchecked")
protected void processConnectKey(SelectionKey curKey) throws IOException {
T session = (T) curKey.attachment();
setCurSession(session);
SocketChannel channel = (SocketChannel) curKey.channel();
NIOHandler curNIOHandler = session.getCurNIOHandler();
if (curNIOHandler instanceof BackendNIOHandler) {
BackendNIOHandler handler = (BackendNIOHandler) curNIOHandler;
try {
if (channel.finishConnect()) {
handler.onConnect(curKey, session, true, null);
} else {
handler.onConnect(curKey, session, false, new ConnectException());
}
} catch (Exception e) {
handler.onConnect(curKey, session, false, e);
}
}
}
Aggregations