use of com.generallycloud.baseio.balance.reverse.BalanceReverseSocketSession in project baseio by generallycloud.
the class SimpleNextRouter method getNextRouterSession.
private BalanceReverseSocketSession getNextRouterSession() {
List<BalanceReverseSocketSession> list = this.routerList;
if (list.isEmpty()) {
return null;
}
BalanceReverseSocketSession session;
if (index < list.size()) {
session = list.get(index++);
} else {
index = 1;
session = list.get(0);
}
return session;
}
use of com.generallycloud.baseio.balance.reverse.BalanceReverseSocketSession in project baseio by generallycloud.
the class SimpleNextRouter method getRouterSessionFresh.
private BalanceReverseSocketSession getRouterSessionFresh(BalanceFacadeSocketSession session) {
ReentrantLock lock = this.lock;
lock.lock();
try {
BalanceReverseSocketSession router_session = getRouterSession(session);
if (router_session == null || router_session.isClosed()) {
router_session = getNextRouterSession();
if (router_session == null) {
return null;
}
session.setReverseSocketSession(router_session);
}
return router_session;
} finally {
lock.unlock();
}
}
use of com.generallycloud.baseio.balance.reverse.BalanceReverseSocketSession in project baseio by generallycloud.
the class BalanceFacadeAcceptorHandler method accept.
@Override
public void accept(SocketSession session, Future future) throws Exception {
BalanceFacadeSocketSession fs = (BalanceFacadeSocketSession) session;
BalanceFuture f = (BalanceFuture) future;
if (facadeInterceptor.intercept(fs, f)) {
logger.info("msg intercepted [ {} ], msg: {}", fs.getRemoteSocketAddress(), f);
return;
}
BalanceReverseSocketSession rs = balanceRouter.getRouterSession(fs, f);
if (rs == null || rs.isClosed()) {
noneLoadReadFutureAcceptor.accept(fs, f, balanceReverseLogger);
return;
}
doAccept(fs, rs, f);
}
use of com.generallycloud.baseio.balance.reverse.BalanceReverseSocketSession in project baseio by generallycloud.
the class BalanceFacadeAcceptorSEListener method sessionClosed.
@Override
public void sessionClosed(SocketSession session) {
BalanceFacadeSocketSession fs = (BalanceFacadeSocketSession) session;
balanceRouter.removeClientSession(fs);
logger.info("client from [ {} ] disconnected.", session.getRemoteSocketAddress());
BalanceRouter balanceRouter = balanceContext.getBalanceRouter();
BalanceReverseSocketSession rs = balanceRouter.getRouterSession(fs);
if (rs == null) {
return;
}
ChannelLostFutureFactory factory = balanceContext.getChannelLostReadFutureFactory();
if (factory == null) {
return;
}
rs.flush(factory.createChannelLostPacket(fs));
}
Aggregations