예제 #1
0
static rstatus_t
stats_pool_init(struct stats_pool *stp, struct server_pool *sp)
{
    rstatus_t status;

    stp->name = sp->name;
    array_null(&stp->metric);
    array_null(&stp->server);

    status = stats_pool_metric_init(&stp->metric);
    if (status != NC_OK) {
        return status;
    }

    status = stats_server_map(&stp->server, &sp->server);
    if (status != NC_OK) {
        stats_metric_deinit(&stp->metric);
        return status;
    }

    log_debug(LOG_VVVERB, "init stats pool '%.*s' with %"PRIu32" metric and "
              "%"PRIu32" server", stp->name.len, stp->name.data,
              array_n(&stp->metric), array_n(&stp->metric));

    return NC_OK;
}
//把stats_pool_codec数组成员赋值给stats_pool->metric数组
//把stats_server_codec数组成员赋值给stats_pool->server数组中的相关成员
static rstatus_t
stats_pool_init(struct stats_pool *stp, struct server_pool *sp)
{
    rstatus_t status;

    stp->name = sp->name;
    array_null(&stp->metric);
    array_null(&stp->server);

    //把stats_pool_codec中的成员拷贝到stats_pool->metric
    status = stats_pool_metric_init(&stp->metric);//把stats_pool_codec数组成员赋值给stats_pool->metric数组
    if (status != NC_OK) {
        return status;
    }

    //把stats_server_codec数组成员赋值给stats_pool->server数组中的相关成员
    //大server中的server:配置列表有多少个,这里的stats_pool->server数组就有多少个成员
    status = stats_server_map(&stp->server, &sp->server); //sp->server这个是配置文件中每个大server中对应的servers:
    if (status != NC_OK) {
        stats_metric_deinit(&stp->metric);
        return status;
    }

    log_debug(LOG_VVVERB, "init stats pool '%.*s' with %"PRIu32" metric and "
              "%"PRIu32" server", stp->name.len, stp->name.data,
              array_n(&stp->metric), array_n(&stp->metric));

    return NC_OK;
}
예제 #3
0
파일: nc_stats.c 프로젝트: YongMan/r3proxy
void
stats_pool_copy_deinit(struct stats_pool *stp, struct hash_table **sit)
{
    uint32_t nserver;
    uint32_t i;
    struct stats_server *sts;

    stats_metric_deinit(&stp->metric);
    string_deinit(&stp->name);

    nserver = array_n(&stp->server);
    for (i = 0;i < nserver;i++) {
        sts = array_pop(&stp->server);
        string_deinit(&stp->name);

        stats_metric_deinit(&sts->metric);
    }
    array_deinit(&stp->server);

    assoc_destroy_table(*sit);
    (*sit) = NULL;
}
예제 #4
0
static void
stats_server_unmap(struct array *stats_server)
{
    uint32_t i, nserver;

    nserver = array_n(stats_server);

    for (i = 0; i < nserver; i++) {
        struct stats_server *sts = array_pop(stats_server);
        stats_metric_deinit(&sts->metric);
    }
    array_deinit(stats_server);

    log_debug(LOG_VVVERB, "unmap %"PRIu32" stats servers", nserver);
}
예제 #5
0
static void
stats_pool_unmap(struct array *stats_pool)
{
    uint32_t i, npool;

    npool = array_n(stats_pool);

    for (i = 0; i < npool; i++) {
        struct stats_pool *stp = array_pop(stats_pool);
        stats_metric_deinit(&stp->metric);
        stats_server_unmap(&stp->server);
    }
    array_deinit(stats_pool);

    log_debug(LOG_VVVERB, "unmap %"PRIu32" stats pool", npool);
}