Search in sources :

Example 1 with BalanceFuture

use of com.generallycloud.baseio.balance.BalanceFuture 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);
}
Also used : BalanceReverseSocketSession(com.generallycloud.baseio.balance.reverse.BalanceReverseSocketSession) BalanceFuture(com.generallycloud.baseio.balance.BalanceFuture)

Example 2 with BalanceFuture

use of com.generallycloud.baseio.balance.BalanceFuture in project baseio by generallycloud.

the class BalanceReverseAcceptorHandler method accept.

@Override
public void accept(SocketSession session, Future future) throws Exception {
    BalanceFuture f = (BalanceFuture) future;
    if (f.isBroadcast()) {
        balanceFacadeAcceptor.getAcceptor().broadcast(f.translate());
        balanceReverseLogger.logBroadcast(session, future, logger);
        return;
    }
    SocketSession response = balanceRouter.getClientSession(f.getSessionKey());
    if (response == null || response.isClosed()) {
        balanceReverseLogger.logPushLost(session, future, logger);
        return;
    }
    response.flush(f.translate());
    balanceReverseLogger.logPush(session, response, future, logger);
}
Also used : SocketSession(com.generallycloud.baseio.component.SocketSession) BalanceFuture(com.generallycloud.baseio.balance.BalanceFuture)

Aggregations

BalanceFuture (com.generallycloud.baseio.balance.BalanceFuture)2 BalanceReverseSocketSession (com.generallycloud.baseio.balance.reverse.BalanceReverseSocketSession)1 SocketSession (com.generallycloud.baseio.component.SocketSession)1