Search in sources :

Example 1 with BalanceFacadeSocketSessionFactory

use of com.generallycloud.baseio.balance.facade.BalanceFacadeSocketSessionFactory in project baseio by generallycloud.

the class BalanceServerBootStrap method startup.

public void startup() throws IOException {
    if (balanceRouter == null) {
        balanceRouter = new SimpleNextRouter();
    }
    if (facadeInterceptor == null) {
        facadeInterceptor = new FacadeInterceptorImpl(5, 50000);
    }
    if (balanceReverseLogger == null) {
        balanceReverseLogger = new BalanceReverseLogger();
    }
    if (noneLoadReadFutureAcceptor == null) {
        noneLoadReadFutureAcceptor = new DefaultNoneLoadFutureAcceptor();
    }
    if (facadeExceptionCaughtHandle == null) {
        facadeExceptionCaughtHandle = new SilentExceptionCaughtHandle();
    }
    if (reverseExceptionCaughtHandle == null) {
        reverseExceptionCaughtHandle = new SilentExceptionCaughtHandle();
    }
    BalanceContext balanceContext = new BalanceContext();
    balanceContext.setChannelLostReadFutureFactory(channelLostReadFutureFactory);
    balanceContext.setNoneLoadReadFutureAcceptor(noneLoadReadFutureAcceptor);
    balanceContext.setReverseExceptionCaughtHandle(reverseExceptionCaughtHandle);
    balanceContext.setFacadeExceptionCaughtHandle(facadeExceptionCaughtHandle);
    balanceContext.setBalanceReverseLogger(balanceReverseLogger);
    balanceContext.setFacadeInterceptor(facadeInterceptor);
    balanceContext.setBalanceRouter(balanceRouter);
    if (balanceFacadeAcceptorHandler == null) {
        balanceFacadeAcceptorHandler = new SessionIdBalanceFacadeAcceptorHandler(balanceContext);
    }
    balanceContext.setBalanceFacadeAcceptorHandler(balanceFacadeAcceptorHandler);
    balanceContext.initialize();
    balanceFacadeAcceptor = balanceContext.getBalanceFacadeAcceptor();
    SocketChannelContext balanceChannelContext = getBalanceChannelContext(balanceContext, balanceServerConfiguration, balanceProtocolFactory);
    balanceChannelContext.setSocketSessionFactory(new BalanceFacadeSocketSessionFactory());
    SocketChannelContext balanceReverseChannelContext = getBalanceReverseChannelContext(balanceContext, balanceReverseServerConfiguration, balanceReverseProtocolFactory);
    balanceReverseChannelContext.setSocketSessionFactory(new BalanceReverseSocketSessionFactory());
    balanceFacadeAcceptor.start(balanceContext, balanceChannelContext, balanceReverseChannelContext);
}
Also used : SilentExceptionCaughtHandle(com.generallycloud.baseio.component.SilentExceptionCaughtHandle) SimpleNextRouter(com.generallycloud.baseio.balance.router.SimpleNextRouter) BalanceReverseSocketSessionFactory(com.generallycloud.baseio.balance.reverse.BalanceReverseSocketSessionFactory) BalanceReverseLogger(com.generallycloud.baseio.balance.reverse.BalanceReverseLogger) SessionIdBalanceFacadeAcceptorHandler(com.generallycloud.baseio.balance.facade.SessionIdBalanceFacadeAcceptorHandler) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext) SocketChannelContext(com.generallycloud.baseio.component.SocketChannelContext) BalanceFacadeSocketSessionFactory(com.generallycloud.baseio.balance.facade.BalanceFacadeSocketSessionFactory)

Aggregations

BalanceFacadeSocketSessionFactory (com.generallycloud.baseio.balance.facade.BalanceFacadeSocketSessionFactory)1 SessionIdBalanceFacadeAcceptorHandler (com.generallycloud.baseio.balance.facade.SessionIdBalanceFacadeAcceptorHandler)1 BalanceReverseLogger (com.generallycloud.baseio.balance.reverse.BalanceReverseLogger)1 BalanceReverseSocketSessionFactory (com.generallycloud.baseio.balance.reverse.BalanceReverseSocketSessionFactory)1 SimpleNextRouter (com.generallycloud.baseio.balance.router.SimpleNextRouter)1 NioSocketChannelContext (com.generallycloud.baseio.component.NioSocketChannelContext)1 SilentExceptionCaughtHandle (com.generallycloud.baseio.component.SilentExceptionCaughtHandle)1 SocketChannelContext (com.generallycloud.baseio.component.SocketChannelContext)1