Пример #1
0
error_code service_node::start()
{
    error_code err = ERR_OK;

    // init data dir
    if (!dsn::utils::filesystem::path_exists(spec().data_dir))
        dsn::utils::filesystem::create_directory(spec().data_dir);

    // init task engine    
    _computation = new task_engine(this);
    _computation->create(_app_spec.pools);    
    dassert (!_computation->is_started(), 
        "task engine must not be started at this point");

    // init per node io engines
    err = init_io_engine(_per_node_io, IOE_PER_NODE);
    if (err != ERR_OK) return err;
    _ios.push_back(_per_node_io);

    // init per queue io engines
    for (auto& pl : _computation->pools())
    {
        if (pl == nullptr)
            continue;

        for (auto& q : pl->queues())
        {
            io_engine io;
            io.q = q;
            io.pool = pl;

            err = init_io_engine(io, IOE_PER_QUEUE);
            if (err != ERR_OK) return err;
            _per_queue_ios[q] = io;

            _ios.push_back(io);
        }
    }

    // start io engines (only computation and timer), others are started in app start task
    for (auto& io : _ios)
    {
        start_io_engine_in_main(io);
    }

    // start task engine
    _computation->start();
    dassert(_computation->is_started(), 
        "task engine must be started at this point");

    // create app
    {
        ::dsn::tools::node_scoper scoper(this);
        _app_context_ptr = _app_spec.role.create(_app_spec.role.type_name.c_str());
    }

    return err;
}
Пример #2
0
error_code service_node::start()
{
    error_code err = ERR_OK;

    // init task engine    
    _computation = new task_engine(this);
    _computation->create(_app_spec.pools);    
    dassert (!_computation->is_started(), 
        "task engine must not be started at this point");

    // init per node io engines
    err = init_io_engine(_per_node_io, IOE_PER_NODE);
    if (err != ERR_OK) return err;
    _ios.push_back(_per_node_io);

    // init per queue io engines
    for (auto& pl : _computation->pools())
    {
        if (pl == nullptr)
            continue;

        for (auto& q : pl->queues())
        {
            io_engine io;
            io.q = q;
            io.pool = pl;

            err = init_io_engine(io, IOE_PER_QUEUE);
            if (err != ERR_OK) return err;
            _per_queue_ios[q] = io;

            _ios.push_back(io);
        }
    }

    // start io engines (only computation and timer), others are started in app start task
    for (auto& io : _ios)
    {
        start_io_engine_in_main(io);
    }

    // start task engine
    _computation->start();
    dassert(_computation->is_started(), 
        "task engine must be started at this point");

    return err;
}