Пример #1
0
/*
 * storaged profiling
 */
static void connect_to_storaged_profil() {
    int i, j;
    spp_profiler_t profiler;
    strncpy(profiler_client.sp[0].host, profiled_host, ROZOFS_HOSTNAME_MAX);
    profiler_client.sp[0].port = profiling_port;
    profiler_client.sp[0].timeout = RPROF_TIMEOUT_REQUESTS;

    // Connect to master process
    if (sp_client_initialize(&profiler_client.sp[0]) != 0) {
        fprintf(stderr,
                "failed to connect (master service profiling) to %s: %s\n",
                profiled_host, strerror(errno));
        exit(EXIT_FAILURE);
    }

    // Need to get monitor values (nb_io_processes and nb_rb_processes)
    if (sp_client_get_profiler(&profiler_client.sp[0], &profiler) != 0) {
        fprintf(stderr, "failed to get master profiler from %s: %s\n",
                profiled_host, strerror(errno));
        exit(EXIT_FAILURE);
    }

    // Establishing a connection for each io process
    for (i = 0; i < profiler.nb_io_processes; i++) {
        strncpy(profiler_client.sp[i + 1].host, profiled_host, ROZOFS_HOSTNAME_MAX);
        profiler_client.sp[i + 1].port = profiler.io_process_ports[i];
        profiler_client.sp[i + 1].timeout = RPROF_TIMEOUT_REQUESTS;
        if (sp_client_initialize(&profiler_client.sp[i + 1]) != 0) {
            fprintf(stderr,
                    "failed to connect (rbs service profiling) to %s: %s\n",
                    profiled_host, strerror(errno));
            exit(EXIT_FAILURE);
        }
    }

    // Establishing a connection for each rebuild process
    for (i = 0; i < profiler.nb_rb_processes; i++) {

        j = profiler.nb_io_processes + i + 1;

        strncpy(profiler_client.sp[j].host, profiled_host, ROZOFS_HOSTNAME_MAX);
        profiler_client.sp[j].port = profiler.rb_process_ports[i];
        profiler_client.sp[j].timeout = RPROF_TIMEOUT_REQUESTS;
        if (sp_client_initialize(&profiler_client.sp[j]) != 0) {
            // Here error is considered normal because it's possible that the
            // rebuild process is completed the rebuild
            profiler_client.sp[j].port = 0;
        }
    }
}
Пример #2
0
/*
 * storaged profiling
 */
static void connect_to_storaged_profil() {
    int i;
    spp_profiler_t profiler;
    strcpy(profiler_client.sp[0].host, profiled_host);
    profiler_client.sp[0].port = profiling_port;
    if (sp_client_initialize(&profiler_client.sp[0]) != 0) {
        fprintf(stderr, "failed to connect to %s: %s\n", profiled_host, strerror(errno));
        exit(EXIT_FAILURE);
    }
    if (sp_client_get_profiler(&profiler_client.sp[0], &profiler) != 0) {
        fprintf(stderr, "failed to connect to %s: %s\n", profiled_host, strerror(errno));
        exit(EXIT_FAILURE);
    }
    for (i = 0; i < profiler.nb_io_processes; i++) {
        strcpy(profiler_client.sp[i+1].host, profiled_host);
        profiler_client.sp[i+1].port = profiler.io_process_ports[i];
        if (sp_client_initialize(&profiler_client.sp[i+1]) != 0) {
            fprintf(stderr, "failed to connect to %s: %s\n", profiled_host, strerror(errno));
            exit(EXIT_FAILURE);
        }
    }

}