当前位置: 首页>>代码示例>>Java>>正文


Java NIOAcceptor类代码示例

本文整理汇总了Java中com.alibaba.cobar.net.NIOAcceptor的典型用法代码示例。如果您正苦于以下问题:Java NIOAcceptor类的具体用法?Java NIOAcceptor怎么用?Java NIOAcceptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NIOAcceptor类属于com.alibaba.cobar.net包,在下文中一共展示了NIOAcceptor类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startup

import com.alibaba.cobar.net.NIOAcceptor; //导入依赖的package包/类
public void startup() throws IOException {
    String name = config.getServerName();
    LOGGER.info("===============================================");
    LOGGER.info(name + " is ready to startup ...");

    // schedule timer task
    timer = new Timer(name + "Timer", true);
    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            TimeUtil.update();
        }
    }, 0L, TIME_UPDATE_PERIOD);
    LOGGER.info("Task Timer is started ...");

    // startup processors
    processors = new NIOProcessor[Runtime.getRuntime().availableProcessors()];
    for (int i = 0; i < processors.length; i++) {
        processors[i] = new NIOProcessor(name + "Processor" + i);
        processors[i].startup();
    }

    // startup server
    SampleConnectionFactory factory = new SampleConnectionFactory();
    server = new NIOAcceptor(name + "Server", SERVER_PORT, factory);
    server.setProcessors(processors);
    server.start();
    LOGGER.info(server.getName() + " is started and listening on " + server.getPort());

    // end
    LOGGER.info("===============================================");
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:33,代码来源:SampleServer.java

示例2: doInit

import com.alibaba.cobar.net.NIOAcceptor; //导入依赖的package包/类
@Override
protected void doInit() throws TddlException {
    try {
        // server startup
        logger.info("===============================================");
        logger.info(NAME + " is ready to startup ...");
        SystemConfig system = config.getSystem();
        logger.info("Startup Cluster : " + system.getClusterName());
        timer.schedule(updateTime(), 0L, system.getTimeUpdatePeriod());
        this.config.init();

        // startup processors
        logger.info("Startup processors ...");
        int handler = system.getProcessorHandler();
        int killExecutor = system.getProcessorKillExecutor();
        processors = new NIOProcessor[system.getProcessors()];
        for (int i = 0; i < processors.length; i++) {
            processors[i] = new NIOProcessor("Processor" + i, handler, killExecutor);
            processors[i].startup();
        }
        timer.schedule(processorCheck(), 0L, system.getProcessorCheckPeriod());

        // startup connector
        logger.info("Startup connector ...");
        connector = new NIOConnector(NAME + "Connector");
        connector.setProcessors(processors);
        connector.start();

        // startup manager
        ManagerConnectionFactory mf = new ManagerConnectionFactory();
        mf.setCharset(system.getCharset());
        mf.setIdleTimeout(system.getIdleTimeout());
        manager = new NIOAcceptor(NAME + "Manager", system.getManagerPort(), mf);
        manager.setProcessors(processors);
        manager.start();
        logger.info(manager.getName() + " is started and listening on " + manager.getPort());

        // startup server
        ServerConnectionFactory sf = new ServerConnectionFactory();
        sf.setCharset(system.getCharset());
        sf.setIdleTimeout(system.getIdleTimeout());
        server = new NIOAcceptor(NAME + "Server", system.getServerPort(), sf);
        server.setProcessors(processors);
        server.start();

        // server started
        logger.info(server.getName() + " is started and listening on " + server.getPort());
        logger.info("===============================================");
        this.startupTime = TimeUtil.currentTimeMillis();
    } catch (Throwable e) {
        throw new TddlException(ErrorCode.ERR_SERVER, e, "start failed");
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:54,代码来源:CobarServer.java

示例3: startup

import com.alibaba.cobar.net.NIOAcceptor; //导入依赖的package包/类
public void startup() throws IOException {
    // server startup
    LOGGER.info("===============================================");
    LOGGER.info(NAME + " is ready to startup ...");
    SystemConfig system = config.getSystem();
    timer.schedule(updateTime(), 0L, TIME_UPDATE_PERIOD);

    // startup processors
    LOGGER.info("Startup processors ...");
    int handler = system.getProcessorHandler();
    int executor = system.getProcessorExecutor();
    int committer = system.getProcessorCommitter();
    processors = new NIOProcessor[system.getProcessors()];
    for (int i = 0; i < processors.length; i++) {
        processors[i] = new NIOProcessor("Processor" + i, handler, executor, committer);
        processors[i].startup();
    }
    timer.schedule(processorCheck(), 0L, system.getProcessorCheckPeriod());

    // startup connector
    LOGGER.info("Startup connector ...");
    connector = new NIOConnector(NAME + "Connector");
    connector.setProcessors(processors);
    connector.start();

    // init dataNodes
    Map<String, MySQLDataNode> dataNodes = config.getDataNodes();
    LOGGER.info("Initialize dataNodes ...");
    for (MySQLDataNode node : dataNodes.values()) {
        node.init(1, 0);
    }
    timer.schedule(dataNodeIdleCheck(), 0L, system.getDataNodeIdleCheckPeriod());
    timer.schedule(dataNodeHeartbeat(), 0L, system.getDataNodeHeartbeatPeriod());

    // startup manager
    ManagerConnectionFactory mf = new ManagerConnectionFactory();
    mf.setCharset(system.getCharset());
    mf.setIdleTimeout(system.getIdleTimeout());
    manager = new NIOAcceptor(NAME + "Manager", system.getManagerPort(), mf);
    manager.setProcessors(processors);
    manager.start();
    LOGGER.info(manager.getName() + " is started and listening on " + manager.getPort());

    // startup server
    ServerConnectionFactory sf = new ServerConnectionFactory();
    sf.setCharset(system.getCharset());
    sf.setIdleTimeout(system.getIdleTimeout());
    server = new NIOAcceptor(NAME + "Server", system.getServerPort(), sf);
    server.setProcessors(processors);
    server.start();
    timer.schedule(clusterHeartbeat(), 0L, system.getClusterHeartbeatPeriod());

    // server started
    LOGGER.info(server.getName() + " is started and listening on " + server.getPort());
    LOGGER.info("===============================================");
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:57,代码来源:CobarServer.java


注:本文中的com.alibaba.cobar.net.NIOAcceptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。