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


C++ DB_APP类代码示例

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


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

示例1: scale_versions

// "avg" is the average PFC for this app
// over CPU versions or GPU versions, whichever is lowest.
// Update the pfc_scale of this app's versions in the DB,
// and update app.min_avg_pfc
//
int scale_versions(APP& app, double avg, SCHED_SHMEM* ssp) {
    char buf[256];
    int retval;

    for (int j=0; j<ssp->napp_versions; j++) {
        APP_VERSION& av = ssp->app_versions[j];
        if (av.appid != app.id) continue;
        if (av.pfc.n < MIN_VERSION_SAMPLES) continue;
        av.pfc_scale= avg/av.pfc.get_avg();

        DB_APP_VERSION dav;
        dav.id = av.id;
        sprintf(buf, "pfc_scale=%.15e", av.pfc_scale);
        retval = dav.update_field(buf);
        if (retval) return retval;
        if (config.debug_credit) {
            PLATFORM* p = ssp->lookup_platform_id(av.platformid);
            log_messages.printf(MSG_NORMAL,
                " updating scale factor for %d (%s %s)\n",
                av.id, p->name, av.plan_class
            );
            log_messages.printf(MSG_NORMAL,
                "  n: %g avg PFC: %g new scale: %g\n",
                av.pfc.n, av.pfc.get_avg(), av.pfc_scale
            );
        }
    }
    app.min_avg_pfc = avg;
    DB_APP da;
    da.id = app.id;
    sprintf(buf, "min_avg_pfc=%.15e", avg);
    retval = da.update_field(buf);
    if (retval) return retval;
    return 0;
}
开发者ID:Rytiss,项目名称:native-boinc-for-android,代码行数:40,代码来源:credit.cpp

示例2: main

int main(int argc, char** argv) {
    DB_APP app;
    int retval;
    int i;
    char download_dir[256], db_name[256], db_passwd[256];
    char db_user[256],db_host[256];
    char buf[4096];
    JOB_DESC jd;
    bool show_wu_name = true;
    bool use_stdin = false;

    strcpy(app.name, "");
    strcpy(db_passwd, "");
    const char* config_dir = 0;
    i = 1;

    while (i < argc) {
        if (arg(argv, i, "appname")) {
            safe_strcpy(app.name, argv[++i]);
        } else if (arg(argv, i, "d")) {
            int dl = atoi(argv[++i]);
            log_messages.set_debug_level(dl);
            if (dl ==4) g_print_queries = true;
        } else if (arg(argv, i, "wu_name")) {
            show_wu_name = false;
            safe_strcpy(jd.wu.name, argv[++i]);
        } else if (arg(argv, i, "wu_template")) {
            safe_strcpy(jd.wu_template_file, argv[++i]);
        } else if (arg(argv, i, "result_template")) {
            safe_strcpy(jd.result_template_file, argv[++i]);
        } else if (arg(argv, i, "config_dir")) {
            config_dir = argv[++i];
        } else if (arg(argv, i, "batch")) {
            jd.wu.batch = atoi(argv[++i]);
        } else if (arg(argv, i, "priority")) {
            jd.wu.priority = atoi(argv[++i]);
        } else if (arg(argv, i, "credit")) {
            jd.wu.canonical_credit = atof(argv[++i]);
        } else if (arg(argv, i, "rsc_fpops_est")) {
            jd.wu.rsc_fpops_est = atof(argv[++i]);
        } else if (arg(argv, i, "rsc_fpops_bound")) {
            jd.wu.rsc_fpops_bound = atof(argv[++i]);
        } else if (arg(argv, i, "rsc_memory_bound")) {
            jd.wu.rsc_memory_bound = atof(argv[++i]);
        } else if (arg(argv, i, "size_class")) {
            jd.wu.size_class = atoi(argv[++i]);
        } else if (arg(argv, i, "app_version_num")) {
            jd.wu.app_version_num = atoi(argv[++i]);
        } else if (arg(argv, i, "rsc_disk_bound")) {
            jd.wu.rsc_disk_bound = atof(argv[++i]);
        } else if (arg(argv, i, "delay_bound")) {
            jd.wu.delay_bound = atoi(argv[++i]);
        } else if (arg(argv, i, "hr_class")) {
            jd.wu.hr_class = atoi(argv[++i]);
        } else if (arg(argv, i, "min_quorum")) {
            jd.wu.min_quorum = atoi(argv[++i]);
        } else if (arg(argv, i, "target_nresults")) {
            jd.wu.target_nresults = atoi(argv[++i]);
        } else if (arg(argv, i, "max_error_results")) {
            jd.wu.max_error_results = atoi(argv[++i]);
        } else if (arg(argv, i, "max_total_results")) {
            jd.wu.max_total_results = atoi(argv[++i]);
        } else if (arg(argv, i, "max_success_results")) {
            jd.wu.max_success_results = atoi(argv[++i]);
        } else if (arg(argv, i, "opaque")) {
            jd.wu.opaque = atoi(argv[++i]);
        } else if (arg(argv, i, "command_line")) {
            jd.command_line= argv[++i];
        } else if (arg(argv, i, "wu_id")) {
            jd.wu.id = atoi(argv[++i]);
        } else if (arg(argv, i, "broadcast")) {
            jd.assign_multi = true;
            jd.assign_flag = true;
            jd.assign_type = ASSIGN_NONE;
        } else if (arg(argv, i, "broadcast_user")) {
            jd.assign_flag = true;
            jd.assign_type = ASSIGN_USER;
            jd.assign_multi = true;
            jd.assign_id = atoi(argv[++i]);
            check_assign_id(jd.assign_id);
        } else if (arg(argv, i, "broadcast_team")) {
            jd.assign_flag = true;
            jd.assign_type = ASSIGN_TEAM;
            jd.assign_multi = true;
            jd.assign_id = atoi(argv[++i]);
            check_assign_id(jd.assign_id);
        } else if (arg(argv, i, "target_host")) {
            jd.assign_flag = true;
            jd.assign_type = ASSIGN_HOST;
            jd.assign_id = atoi(argv[++i]);
            check_assign_id(jd.assign_id);
        } else if (arg(argv, i, "target_user")) {
            jd.assign_flag = true;
            jd.assign_type = ASSIGN_USER;
            jd.assign_id = atoi(argv[++i]);
            check_assign_id(jd.assign_id);
        } else if (arg(argv, i, "target_team")) {
            jd.assign_flag = true;
            jd.assign_type = ASSIGN_TEAM;
            jd.assign_id = atoi(argv[++i]);
//.........这里部分代码省略.........
开发者ID:drshawnkwang,项目名称:boinc,代码行数:101,代码来源:create_work.cpp

示例3: main

int main(int argc, char** argv) {
    char buf[256];
    bool no_update = false;
    int userid=0;
    char* app_name = NULL;
    double flop_count = 0;

    for (int i=1; i<argc; i++) {
        if (!strcmp(argv[i], "--no_update")) {
            no_update = true;
        } else if (!strcmp(argv[i], "--user")) {
            userid = atoi(argv[++i]);
        } else if (!strcmp(argv[i], "--app")) {
            app_name = argv[++i];
        } else if (!strcmp(argv[i], "--flops")) {
            flop_count = atof(argv[++i]);
        } else {
            fprintf(stderr, "bad arg: %s\n", argv[i]);
            usage();
        }
    }
    if (!app_name) usage("missing --app\n");
    if (!userid) usage("missing --user\n");
    if (flop_count <= 0) usage("missing --flops\n");

    int retval = config.parse_file();
    if (retval) {
        log_messages.printf(MSG_CRITICAL,
            "Can't parse config.xml: %s\n", boincerror(retval)
        );
        exit(1);
    }
    retval = boinc_db.open(
        config.db_name, config.db_host, config.db_user, config.db_passwd
    );
    if (retval) {
        log_messages.printf(MSG_CRITICAL,
            "boinc_db.open: %d; %s\n", retval, boinc_db.error_string()
        );
        exit(1);
    }

    DB_APP app;
    sprintf(buf, "where name='%s'", app_name);
    retval = app.lookup(buf);
    if (retval) {
        fprintf(stderr, "no such app %s\n", argv[3]);
        exit(1);
    }

    // normalize by the app's min avg PFC
    //
    if (app.min_avg_pfc) {
        flop_count *= app.min_avg_pfc;
    }

    DB_USER user;
    retval = user.lookup_id(userid);
    if (retval) {
        fprintf(stderr, "no such user %d\n", userid);
        exit(1);
    }
    DB_USER_SUBMIT us;
    sprintf(buf, "where user_id=%d", userid);
    retval = us.lookup(buf);
    if (retval) {
        fprintf(stderr, "unauthorized user %d\n", userid);
        exit(1);
    }

    double total_quota, project_flops;
    retval = get_total_quota(total_quota);
    if (retval) {
        fprintf(stderr, "get_total_quota() failed: %d\n", retval);
        exit(1);
    }
    retval = get_project_flops(project_flops);
    if (retval) {
        fprintf(stderr, "get_project_flops() failed: %d\n", retval);
        exit(1);
    }
    double delta = user_priority_delta(
        us, flop_count, total_quota, project_flops
    );

    double x = us.logical_start_time;
    if (x < dtime()) x = dtime();
    x += delta;

    if (!no_update) {
        char set_clause[256], where_clause[256];
        sprintf(set_clause, "logical_start_time=%f", x);
        sprintf(where_clause, "user_id=%d", us.user_id);
        retval = us.update_fields_noid(set_clause, where_clause);
        if (retval) {
            fprintf(stderr, "update_fields_noid() failed: %d\n", retval);
            exit(1);
        }
    }
    printf("%f\n", x);
//.........这里部分代码省略.........
开发者ID:AltroCoin,项目名称:altrocoin,代码行数:101,代码来源:adjust_user_priority.cpp

示例4: main

int main(int argc, char** argv) {
    DB_APP app;
    int retval;
    char wu_template_file[256];
    int i;
    char download_dir[256], db_name[256], db_passwd[256];
    char db_user[256],db_host[256];
    char buf[4096];
    JOB_DESC jd;
    bool show_wu_name = true;
    bool use_stdin = false;

    strcpy(wu_template_file, "");
    strcpy(app.name, "");
    strcpy(db_passwd, "");
    const char* config_dir = 0;
    i = 1;

    while (i < argc) {
        if (arg(argv, i, "appname")) {
            safe_strcpy(app.name, argv[++i]);
        } else if (arg(argv, i, "d")) {
            int dl = atoi(argv[++i]);
            log_messages.set_debug_level(dl);
            if (dl ==4) g_print_queries = true;
        } else if (arg(argv, i, "wu_name")) {
            show_wu_name = false;
            safe_strcpy(jd.wu.name, argv[++i]);
        } else if (arg(argv, i, "wu_template")) {
            safe_strcpy(wu_template_file, argv[++i]);
        } else if (arg(argv, i, "result_template")) {
            safe_strcpy(jd.result_template_file, argv[++i]);
        } else if (arg(argv, i, "config_dir")) {
            config_dir = argv[++i];
        } else if (arg(argv, i, "batch")) {
            jd.wu.batch = atoi(argv[++i]);
        } else if (arg(argv, i, "priority")) {
            jd.wu.priority = atoi(argv[++i]);
        } else if (arg(argv, i, "rsc_fpops_est")) {
            jd.wu.rsc_fpops_est = atof(argv[++i]);
        } else if (arg(argv, i, "rsc_fpops_bound")) {
            jd.wu.rsc_fpops_bound = atof(argv[++i]);
        } else if (arg(argv, i, "rsc_memory_bound")) {
            jd.wu.rsc_memory_bound = atof(argv[++i]);
        } else if (arg(argv, i, "size_class")) {
            jd.wu.size_class = atoi(argv[++i]);
        } else if (arg(argv, i, "rsc_disk_bound")) {
            jd.wu.rsc_disk_bound = atof(argv[++i]);
        } else if (arg(argv, i, "delay_bound")) {
            jd.wu.delay_bound = atoi(argv[++i]);
        } else if (arg(argv, i, "min_quorum")) {
            jd.wu.min_quorum = atoi(argv[++i]);
        } else if (arg(argv, i, "target_nresults")) {
            jd.wu.target_nresults = atoi(argv[++i]);
        } else if (arg(argv, i, "max_error_results")) {
            jd.wu.max_error_results = atoi(argv[++i]);
        } else if (arg(argv, i, "max_total_results")) {
            jd.wu.max_total_results = atoi(argv[++i]);
        } else if (arg(argv, i, "max_success_results")) {
            jd.wu.max_success_results = atoi(argv[++i]);
        } else if (arg(argv, i, "opaque")) {
            jd.wu.opaque = atoi(argv[++i]);
        } else if (arg(argv, i, "command_line")) {
            jd.command_line= argv[++i];
        } else if (arg(argv, i, "additional_xml")) {
            strcpy(jd.additional_xml, argv[++i]);
        } else if (arg(argv, i, "wu_id")) {
            jd.wu.id = atoi(argv[++i]);
        } else if (arg(argv, i, "broadcast")) {
            jd.assign_multi = true;
            jd.assign_flag = true;
            jd.assign_type = ASSIGN_NONE;
        } else if (arg(argv, i, "broadcast_user")) {
            jd.assign_flag = true;
            jd.assign_type = ASSIGN_USER;
            jd.assign_multi = true;
            jd.assign_id = atoi(argv[++i]);
        } else if (arg(argv, i, "broadcast_team")) {
            jd.assign_flag = true;
            jd.assign_type = ASSIGN_TEAM;
            jd.assign_multi = true;
            jd.assign_id = atoi(argv[++i]);
        } else if (arg(argv, i, "target_host")) {
            jd.assign_flag = true;
            jd.assign_type = ASSIGN_HOST;
            jd.assign_id = atoi(argv[++i]);
        } else if (arg(argv, i, "target_user")) {
            jd.assign_flag = true;
            jd.assign_type = ASSIGN_USER;
            jd.assign_id = atoi(argv[++i]);
        } else if (arg(argv, i, "target_team")) {
            jd.assign_flag = true;
            jd.assign_type = ASSIGN_TEAM;
            jd.assign_id = atoi(argv[++i]);
        } else if (arg(argv, i, "help")) {
            usage();
            exit(0);
        } else if (arg(argv, i, "stdin")) {
            use_stdin = true;
        } else if (arg(argv, i, (char*)"remote_file")) {
//.........这里部分代码省略.........
开发者ID:hanxue,项目名称:Boinc,代码行数:101,代码来源:create_work.cpp

示例5: main

int main(int argc, char** argv) {
    int retval;
    DB_APP app;
    int i;
    char buf[256];

    strcpy(app.name, "");
    check_stop_daemons();
    g_argc = argc;
    g_argv = argv;
    for (i=1; i<argc; i++) {
         if (is_arg(argv[i], "sleep_interval")) {
            sleep_interval = atoi(argv[++i]);
        } else if (is_arg(argv[i], "d") || is_arg(argv[i], "debug_level")) {
            int dl = atoi(argv[++i]);
            log_messages.set_debug_level(dl);
            if (dl ==4) g_print_queries = true;
        } else if (is_arg(argv[i], "app")) {
            strcpy(app.name, argv[++i]);
        } else if (is_arg(argv[i], "dont_update_db")) {
            // This option is for testing your assimilator.  When set,
            // it ensures that the assimilator does not actually modify
            // the assimilate_state of the workunits, so you can run
            // your assimilator over and over again without affecting
            // your project.
            update_db = false;
        } else if (is_arg(argv[i], "help") || is_arg(argv[i], "h")) {
//            usage(argv);
        } else {
            log_messages.printf(MSG_CRITICAL, "Unrecognized arg: %s\n", argv[i]);
//            usage(argv);
        }
    }

    if (!strlen(app.name)) {
//        usage(argv);
    }

    retval = config.parse_file();
    if (retval) {
        log_messages.printf(MSG_CRITICAL, "Can't parse config.xml: %s\n", boincerror(retval));
        exit(1);
    }

    log_messages.printf(MSG_NORMAL, "Starting\n");

    retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd);
    if (retval) {
        log_messages.printf(MSG_CRITICAL, "Can't open DB\n");
        exit(1);
    }
    sprintf(buf, "where name='%s'", app.name);
    retval = app.lookup(buf);
    if (retval) {
        log_messages.printf(MSG_CRITICAL, "Can't find app\n");
        exit(1);
    }
    install_stop_signal_handler();

    main_loop(app);
}
开发者ID:Zarbis,项目名称:test,代码行数:61,代码来源:assimilator_text.cpp

示例6: scan_tables

int SCHED_SHMEM::scan_tables() {
    DB_PLATFORM platform;
    DB_APP app;
    DB_APP_VERSION app_version;
    DB_ASSIGNMENT assignment;
    int i, j, n;

    n = 0;
    while (!platform.enumerate("where deprecated=0")) {
        platforms[n++] = platform;
        if (n == MAX_PLATFORMS) {
            overflow("platforms", "MAX_PLATFORMS");
        }
    }
    nplatforms = n;

    n = 0;
    app_weight_sum = 0;
    while (!app.enumerate("where deprecated=0")) {
        if (n == MAX_APPS) {
            overflow("apps", "MAX_APPS");
        }
        app_weight_sum += app.weight;
        if (app.locality_scheduling == LOCALITY_SCHED_LITE) {
            locality_sched_lite = true;
        }
        if (app.non_cpu_intensive) {
            have_nci_app = true;
        }
        if (config.non_cpu_intensive) {
            have_nci_app = true;
            app.non_cpu_intensive = true;
        }
        if (app.n_size_classes > 1) {
            char path[MAXPATHLEN];
            sprintf(path, "../size_census_%s", app.name);
#ifndef _USING_FCGI_
            FILE* f = fopen(path, "r");
#else
            FCGI_FILE* f = FCGI::fopen(path, "r");
#endif
            if (!f) {
                log_messages.printf(MSG_CRITICAL,
                    "Missing size census file for app %s\n", app.name
                );
                return ERR_FOPEN;
            }
            for (int i=0; i<app.n_size_classes-1; i++) {
                char buf[256];
                char* p = fgets(buf, 256, f);
                if (!p) {
                    log_messages.printf(MSG_CRITICAL,
                        "Size census file for app %s is too short\n", app.name
                    );
                    return ERR_XML_PARSE;   // whatever
                }
                app.size_class_quantiles[i] = atof(buf);
            }
            fclose(f);
        }
        apps[n++] = app;
    }
    napps = n;

    n = 0;

    // for each (app, platform) pair,
    // get all versions with numbers maximal in their plan class.
    //
    for (i=0; i<nplatforms; i++) {
        PLATFORM& splatform = platforms[i];
        for (j=0; j<napps; j++) {
            APP& sapp = apps[j];
            vector<APP_VERSION> avs;
            char query[1024];
            sprintf(query,
                "where appid=%d and platformid=%d and deprecated=0",
                sapp.id, splatform.id
            );
            while (!app_version.enumerate(query)) {
                avs.push_back(app_version);
            }
            for (unsigned int k=0; k<avs.size(); k++) {
                APP_VERSION& av1 = avs[k];
                for (unsigned int kk=0; kk<avs.size(); kk++) {
                    if (k == kk) continue;
                    APP_VERSION& av2 = avs[kk];
                    if (!strcmp(av1.plan_class, av2.plan_class) && av1.version_num > av2.version_num) {
                        av2.deprecated = 1;
                    }
                }
            }
            for (unsigned int k=0; k<avs.size(); k++) {
                APP_VERSION& av1 = avs[k];
                if (av1.deprecated) continue;
                if (av1.min_core_version && av1.min_core_version < 10000) {
                    fprintf(stderr, "min core version too small - multiplying by 100\n");
                    av1.min_core_version *= 100;
                }
                if (av1.max_core_version && av1.max_core_version < 10000) {
//.........这里部分代码省略.........
开发者ID:niclaslockner,项目名称:boinc,代码行数:101,代码来源:sched_shmem.cpp

示例7: main

int main(int argc, char** argv) {
    int retval;
    bool one_pass = false;
    DB_APP app;
    int i;
    char buf[256];

    strcpy(app.name, "");
    check_stop_daemons();
    g_argc = argc;
    g_argv = argv;
    for (i=1; i<argc; i++) {
        if (is_arg(argv[i], "one_pass_N_WU")) {
            one_pass_N_WU = atoi(argv[++i]);
            one_pass = true;
        } else if (is_arg(argv[i], "sleep_interval")) {
            sleep_interval = atoi(argv[++i]);
        } else if (is_arg(argv[i], "one_pass")) {
            one_pass = true;
        } else if (is_arg(argv[i], "d") || is_arg(argv[i], "debug_level")) {
            int dl = atoi(argv[++i]);
            log_messages.set_debug_level(dl);
            if (dl ==4) g_print_queries = true;
        } else if (is_arg(argv[i], "app")) {
            strcpy(app.name, argv[++i]);
        } else if (is_arg(argv[i], "dont_update_db")) {
            // This option is for testing your assimilator.  When set,
            // it ensures that the assimilator does not actually modify
            // the assimilate_state of the workunits, so you can run
            // your assimilator over and over again without affecting
            // your project.
            update_db = false;
        } else if (is_arg(argv[i], "noinsert")) {
            // This option is also for testing and is used to
            // prevent the inserting of results into the *backend*
            // (as opposed to the boinc) DB.
            noinsert = true;
        } else if (is_arg(argv[i], "mod")) {
            wu_id_modulus   = atoi(argv[++i]);
            wu_id_remainder = atoi(argv[++i]);
        } else if (is_arg(argv[i], "help") || is_arg(argv[i], "h")) {
            usage(argv);
        } else if (is_arg(argv[i], "v") || is_arg(argv[i], "version")) {
            printf("%s\n", SVN_VERSION);
            exit(0);
	} else if (is_arg(argv[i], "results_prefix")) {
	    results_prefix=argv[++i];
	} else if (is_arg(argv[i], "transcripts_prefix")) {
            transcripts_prefix=argv[++i];
        } else {
            log_messages.printf(MSG_CRITICAL, "Unrecognized arg: %s\n", argv[i]);
            usage(argv);
        }
    }

    if (!strlen(app.name)) {
        usage(argv);
    }

    if (wu_id_modulus) {
        log_messages.printf(MSG_DEBUG,
            "Using mod'ed WU enumeration.  modulus = %d  remainder = %d\n",
            wu_id_modulus, wu_id_remainder
        );
    }

    retval = config.parse_file();
    if (retval) {
        log_messages.printf(MSG_CRITICAL,
            "Can't parse config.xml: %s\n", boincerror(retval)
        );
        exit(1);
    }

    log_messages.printf(MSG_NORMAL, "Starting\n");

    retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd);
    if (retval) {
        log_messages.printf(MSG_CRITICAL, "Can't open DB\n");
        exit(1);
    }
    sprintf(buf, "where name='%s'", app.name);
    retval = app.lookup(buf);
    if (retval) {
        log_messages.printf(MSG_CRITICAL, "Can't find app\n");
        exit(1);
    }
    install_stop_signal_handler();
    do {
        if (!do_pass(app)) {
            if (!one_pass) {
                sleep(sleep_interval);
            }
        }
    } while (!one_pass);
}
开发者ID:abergstr,项目名称:BOINC,代码行数:96,代码来源:assimilator.cpp

示例8: main

int main(int argc, char** argv) {
    // Инициализация подключения к dims
    frontend_db = mysql_init(NULL);
    if (frontend_db == NULL) {
        log_messages.printf(MSG_CRITICAL, "Error %u: %s\n", mysql_errno(frontend_db), mysql_error(frontend_db));
        exit(1);
    }
    // Подключение к БД dims
    if (mysql_real_connect(frontend_db, "localhost", "boincadm", "password!stronk!", "dihm1", 0, NULL, 0) == NULL) {
        log_messages.printf(MSG_CRITICAL, "Error %u: %s\n", mysql_errno(frontend_db), mysql_error(frontend_db));
        exit(1);
    }

    int retval;
    DB_APP app;     // http://boinc.berkeley.edu/doxygen/server/html/classDB__APP.html
    int i;
    char buf[256];

    strcpy(app.name, "");
    check_stop_daemons();
    g_argc = argc;
    g_argv = argv;
    for (i=1; i<argc; i++) {
         if (is_arg(argv[i], "sleep_interval")) {
            sleep_interval = atoi(argv[++i]);
        } else if (is_arg(argv[i], "d") || is_arg(argv[i], "debug_level")) {
            int dl = atoi(argv[++i]);
            log_messages.set_debug_level(dl);
            if (dl ==4) g_print_queries = true;
        } else if (is_arg(argv[i], "app")) {
            strcpy(app.name, argv[++i]);
        } else if (is_arg(argv[i], "dont_update_db")) {
            // This option is for testing your assimilator.  When set,
            // it ensures that the assimilator does not actually modify
            // the assimilate_state of the workunits, so you can run
            // your assimilator over and over again without affecting
            // your project.
            update_db = false;
        } else if (is_arg(argv[i], "help") || is_arg(argv[i], "h")) {
//            usage(argv);
        } else {
            log_messages.printf(MSG_CRITICAL, "Unrecognized arg: %s\n", argv[i]);
//            usage(argv);
        }
    }

    if (!strlen(app.name)) {
//        usage(argv);
    }

    retval = config.parse_file();
    if (retval) {
        log_messages.printf(MSG_CRITICAL, "Can't parse config.xml: %s\n", boincerror(retval));
        exit(1);
    }

    log_messages.printf(MSG_NORMAL, "Starting\n");

    retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd);
    if (retval) {
        log_messages.printf(MSG_CRITICAL, "Can't open DB\n");
        exit(1);
    }
    sprintf(buf, "where name='%s'", app.name);
    retval = app.lookup(buf);
    if (retval) {
        log_messages.printf(MSG_CRITICAL, "Can't find app\n");
        exit(1);
    }
    install_stop_signal_handler();

    main_loop(app);
}
开发者ID:Zarbis,项目名称:test,代码行数:73,代码来源:assimilator_plankton.cpp

示例9: main

int main(int argc, const char** argv) {
    DB_APP app;
    DB_WORKUNIT wu;
    int retval;
    char wu_template[BLOB_SIZE];
    char wu_template_file[256], result_template_file[256], result_template_path[1024];
    const char* command_line=NULL;
    const char** infiles = NULL;
    int i, ninfiles;
    char download_dir[256], db_name[256], db_passwd[256];
    char db_user[256],db_host[256];
    char buf[256];
    char additional_xml[256];
    bool assign_flag = false;
    bool assign_multi = false;
    int assign_id = 0;
    int assign_type;

    strcpy(result_template_file, "");
    strcpy(app.name, "");
    strcpy(db_passwd, "");
    strcpy(additional_xml, "");
    const char* config_dir = 0;
    i = 1;
    ninfiles = 0;
    wu.clear();

    // defaults (in case they're not in WU template)

    wu.id = 0;
    wu.min_quorum = 2;
    wu.target_nresults = 2;
    wu.max_error_results = 3;
    wu.max_total_results = 10;
    wu.max_success_results = 6;
    wu.rsc_fpops_est = 3600e9;
    wu.rsc_fpops_bound =  86400e9;
    wu.rsc_memory_bound = 5e8;
    wu.rsc_disk_bound = 1e9;
    wu.rsc_bandwidth_bound = 0.0;
    wu.delay_bound = 7*86400;

    while (i < argc) {
        if (arg(argv, i, "appname")) {
            strcpy(app.name, argv[++i]);
        } else if (arg(argv, i, "wu_name")) {
            strcpy(wu.name, argv[++i]);
        } else if (arg(argv, i, "wu_template")) {
            strcpy(wu_template_file, argv[++i]);
        } else if (arg(argv, i, "result_template")) {
            strcpy(result_template_file, argv[++i]);
        } else if (arg(argv, i, "batch")) {
            wu.batch = atoi(argv[++i]);
        } else if (arg(argv, i, "config_dir")) {
            config_dir = argv[++i];
        } else if (arg(argv, i, "batch")) {
            wu.batch = atoi(argv[++i]);
        } else if (arg(argv, i, "priority")) {
            wu.priority = atoi(argv[++i]);
        } else if (arg(argv, i, "rsc_fpops_est")) {
            wu.rsc_fpops_est = atof(argv[++i]);
        } else if (arg(argv, i, "rsc_fpops_bound")) {
            wu.rsc_fpops_bound = atof(argv[++i]);
        } else if (arg(argv, i, "rsc_memory_bound")) {
            wu.rsc_memory_bound = atof(argv[++i]);
        } else if (arg(argv, i, "rsc_disk_bound")) {
            wu.rsc_disk_bound = atof(argv[++i]);
        } else if (arg(argv, i, "delay_bound")) {
            wu.delay_bound = atoi(argv[++i]);
        } else if (arg(argv, i, "min_quorum")) {
            wu.min_quorum = atoi(argv[++i]);
        } else if (arg(argv, i, "target_nresults")) {
            wu.target_nresults = atoi(argv[++i]);
        } else if (arg(argv, i, "max_error_results")) {
            wu.max_error_results = atoi(argv[++i]);
        } else if (arg(argv, i, "max_total_results")) {
            wu.max_total_results = atoi(argv[++i]);
        } else if (arg(argv, i, "max_success_results")) {
            wu.max_success_results = atoi(argv[++i]);
        } else if (arg(argv, i, "opaque")) {
            wu.opaque = atoi(argv[++i]);
        } else if (arg(argv, i, "command_line")) {
            command_line= argv[++i];
        } else if (arg(argv, i, "additional_xml")) {
            strcpy(additional_xml, argv[++i]);
        } else if (arg(argv, i, "wu_id")) {
            wu.id = atoi(argv[++i]);
        } else if (arg(argv, i, "assign_all")) {
            assign_multi = true;
            assign_flag = true;
            assign_type = ASSIGN_NONE;
        } else if (arg(argv, i, "assign_host")) {
            assign_flag = true;
            assign_type = ASSIGN_HOST;
            assign_id = atoi(argv[++i]);
        } else if (arg(argv, i, "assign_user_one")) {
            assign_flag = true;
            assign_type = ASSIGN_USER;
            assign_id = atoi(argv[++i]);
        } else if (arg(argv, i, "assign_user_all")) {
//.........这里部分代码省略.........
开发者ID:freehal,项目名称:boinc-freehal,代码行数:101,代码来源:create_work.cpp

示例10: make_job

int make_job(struct jobstruct job) {
	DB_APP app;
	DB_WORKUNIT wu;
	char* wu_template;
	const char *infiles[3];
	char *path;
	char additional_xml[512];

	log_messages.printf(MSG_DEBUG, "Making files\n");
	// write input file in the download directory
	//
	infiles[0] = job.nameligand;
	infiles[1] = job.namereceptor;
	infiles[2] = job.confname;

	char path_ligand[1024];
	char path_receptor[1024];
	char path_conf[1024];

	int retval;

	config.download_path(job.nameligand, path_ligand);
	retval = createFile(path_ligand, job.pdbligand);
	if (retval) {
		fprintf(stderr, "error making input data\n");
		exit(1);
	}

	config.download_path(job.namereceptor, path_receptor);
	retval = createFile(path_receptor, job.pdbreceptor);
	if (retval) {
		fprintf(stderr, "error making input data\n");
		exit(1);
	}

	config.download_path(job.confname, path_conf);
	retval = createFile(path_conf, job.pdbconf);
	if (retval) {
		fprintf(stderr, "error making input data\n");
		exit(1);
	}

	log_messages.printf(MSG_DEBUG, "Done making files\n");

	wu.clear();     // zeroes all fields

	if (!strlen(wu.name)) {
		/*sprintf(wu.name, "%s_%d_%f-%s-%s-%s-%s-%s-", app_name, getpid(),
		 dtime(), job.idreceptor, job.namereceptor, job.idligand,
		 job.nameligand, job.experiment);*/
		sprintf(wu.name, "%s_%s_%s_%s", app_name, job.idligand, job.idreceptor,
				job.experiment);
	}

	char buff[256];
	sprintf(buff, "where name='%s'", app_name);
	retval = app.lookup(buff);
	if (retval) {
		fprintf(stderr, "create_work: app not found\n");
		exit(1);
	}

	wu.appid = app.id;
	wu.id = 0;
	wu.min_quorum = 1;
	wu.target_nresults = 1;
	wu.max_error_results = 1;
	wu.max_total_results = 5;
	wu.max_success_results = 1;
	wu.rsc_disk_bound = 150000000;
	wu.rsc_bandwidth_bound = 0.0;

	double value = calcValue(job.pdbligand, job.pdbreceptor);
	std::cout << value << std::endl;
	double credit = CREDIT_CORRECTOR * value;
	double fpops_est = FPOPS_CORRECTOR * value;
	wu.rsc_fpops_est = fpops_est;
	wu.rsc_fpops_bound = fpops_est * fpops_est;


	if (credit > 500) {
		wu.delay_bound = 21 * 86400;
	} else if (credit > 150) {
		wu.delay_bound = 14 * 86400;
	} else {
		wu.delay_bound = 7 * 86400;
	}

	//sprintf(additional_xml, "<credit>%f</credit>\n", credit);

	sprintf(additional_xml,
			"<credit>%f</credit>\n<command_line>--ligand ligand --receptor receptor --config conf --rligand %s --rreceptor %s --cpu 1</command_line>", credit,
			job.nameligand, job.namereceptor);

	log_messages.printf(MSG_DEBUG, "Start create_work()\n");
	create_work(wu, in_template, "templates/vina_result.xml",
			"../templates/vina_result.xml", infiles, 3, config, NULL,
			additional_xml);

	log_messages.printf(MSG_DEBUG, "Done create_work()\n");
//.........这里部分代码省略.........
开发者ID:oXis,项目名称:bin_boinc,代码行数:101,代码来源:work_generator.cpp

示例11: main

int main(int argc, char** argv) {
    int retval;
    bool one_pass = false;
    int i;
    DB_APP app;

    check_stop_daemons();

    *app.name='\0';
    for (i=1; i<argc; i++) {
        if (is_arg(argv[i], "one_pass")) {
            one_pass = true;
        } else if (is_arg(argv[i], "dont_retry_errors")) {
            dont_retry_errors = true;
        } else if (is_arg(argv[i], "preserve_wu_files")) {
            preserve_wu_files = true;
        } else if (is_arg(argv[i], "preserve_result_files")) {
            preserve_result_files = true;
        } else if (is_arg(argv[i], "app")) {
            strcpy(app.name, argv[++i]);
        } else if (is_arg(argv[i], "appid")) {
            if (!argv[++i]) {
                log_messages.printf(MSG_CRITICAL, "%s requires an argument\n\n", argv[--i]);
                usage(argv[0]);
                exit(1);
            }
            appid = atoi(argv[i]);
        } else if (is_arg(argv[i], "d") || is_arg(argv[i], "debug_level")) {
            if (!argv[++i]) {
                log_messages.printf(MSG_CRITICAL, "%s requires an argument\n\n", argv[--i]);
                usage(argv[0]);
                exit(1);
            }
            int dl = atoi(argv[i]);
            log_messages.set_debug_level(dl);
            if (dl == 4) g_print_queries = true;
        } else if (is_arg(argv[i], "mod")) {
            if (!argv[i+1] || !argv[i+2]) {
                log_messages.printf(MSG_CRITICAL, "%s requires two arguments\n\n", argv[i]);
                usage(argv[0]);
                exit(1);
            }
            id_modulus   = atoi(argv[++i]);
            id_remainder = atoi(argv[++i]);
        } else if (is_arg(argv[i], "dont_delete_antiques")) {
            dont_delete_antiques = true;
        } else if (is_arg(argv[i], "delete_antiques_interval")) {
            antique_interval = atoi(argv[++i]);
        } else if (is_arg(argv[i], "delete_antiques_limit")) {
            antique_limit = atoi(argv[++i]);
        } else if (is_arg(argv[i], "dont_delete_batches")) {
            dont_delete_batches = true;
        } else if (is_arg(argv[i], "delete_antiques_now")) {
            antique_delay = 0;
        } else if (is_arg(argv[i], "input_files_only")) {
            do_output_files = false;
            dont_delete_antiques = true;
        } else if (is_arg(argv[i], "output_files_only")) {
            do_input_files = false;
        } else if (is_arg(argv[i], "sleep_interval")) {
            if (!argv[++i]) {
                log_messages.printf(MSG_CRITICAL, "%s requires an argument\n\n", argv[--i]);
                usage(argv[0]);
                exit(1);
            }
            sleep_interval = atoi(argv[i]);
        } else if (is_arg(argv[i], "h") || is_arg(argv[i], "help")) {
            usage(argv[0]);
            exit(0);
        } else if (is_arg(argv[i], "v") || is_arg(argv[i], "version")) {
            printf("%s\n", SVN_VERSION);
            exit(0);
        } else {
            log_messages.printf(MSG_CRITICAL, "unknown command line argument: %s\n\n", argv[i]);
            usage(argv[0]);
            exit(1);
        }
    }

    if (id_modulus) {
        log_messages.printf(MSG_DEBUG,
                            "Using mod'ed WU/result enumeration.  mod = %d  rem = %d\n",
                            id_modulus, id_remainder
                           );
    }

    retval = config.parse_file();
    if (retval) {
        log_messages.printf(MSG_CRITICAL,
                            "Can't parse config.xml: %s\n", boincerror(retval)
                           );
        exit(1);
    }

    log_messages.printf(MSG_NORMAL, "Starting\n");

    retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd);
    if (retval) {
        log_messages.printf(MSG_CRITICAL, "can't open DB\n");
        exit(1);
//.........这里部分代码省略.........
开发者ID:BME-IK,项目名称:gridbee-nacl-framework,代码行数:101,代码来源:file_deleter.cpp

示例12: main_loop

int main_loop() {
    int retval;
    bool did_something;
    char buf[256];

    retval = boinc_db.open(
        config.db_name, config.db_host, config.db_user, config.db_passwd
    );
    if (retval) {
        log_messages.printf(MSG_CRITICAL,
            "boinc_db.open failed: %s\n", boincerror(retval)
        );
        exit(1);
    }

    sprintf(buf, "where name='%s'", app_name);

    while (1) {
        check_stop_daemons();

        // look up app within the loop,
        // in case its min_avg_pfc has been changed by the feeder
        //
        retval = app.lookup(buf);
        if (retval) {
            log_messages.printf(MSG_CRITICAL, "can't find app %s\n", app_name);
            exit(1);
        }
        did_something = do_validate_scan();
        if (!did_something) {
            write_modified_app_versions(app_versions);
            if (one_pass) break;
#ifdef GCL_SIMULATOR
            char nameforsim[64];
            sprintf(nameforsim, "validator%i", app.id);
            continue_simulation(nameforsim);
            signal(SIGUSR2, simulator_signal_handler);
            pause();
#else
            sleep(sleep_interval);
#endif
        }
    }
    return 0;
}
开发者ID:BME-IK,项目名称:gridbee-nacl-framework,代码行数:45,代码来源:validator.cpp

示例13: main_loop

int main_loop() {
    int retval;
    bool did_something;
    char buf[256];

    retval = boinc_db.open(
        config.db_name, config.db_host, config.db_user, config.db_passwd
    );
    if (retval) {
        log_messages.printf(MSG_CRITICAL, "boinc_db.open failed: %d\n", retval);
        exit(1);
    }

    sprintf(buf, "where name='%s'", app_name);
    retval = app.lookup(buf);
    if (retval) {
        log_messages.printf(MSG_CRITICAL, "can't find app %s\n", app_name);
        exit(1);
    }

    while (1) {
        check_stop_daemons();
        did_something = do_validate_scan();
        if (!did_something) {
            if (one_pass) break;
#ifdef GCL_SIMULATOR
            char nameforsim[64];
            sprintf(nameforsim, "validator%i", app.id);
            continue_simulation(nameforsim);
            signal(SIGUSR2, simulator_signal_handler);
            pause();
#else
            sleep(sleep_interval);
#endif
        }
    }
    return 0;
}
开发者ID:Rytiss,项目名称:native-boinc-for-android,代码行数:38,代码来源:validator.cpp

示例14: main

int main(int argc, char** argv) {
    int retval;
    char buf[256];

    for (int i=1; i<argc; i++) {
        if (!strcmp(argv[i], "--app_name")) {
            app_name = argv[++i];
        } else if (!strcmp(argv[i], "--lo")) {
            lo = atoi(argv[++i]);
        } else if (!strcmp(argv[i], "--hi")) {
            hi = atoi(argv[++i]);
        } else if (!strcmp(argv[i], "-d")) {
            log_messages.set_debug_level(atoi(argv[++i]));
        } else if (!strcmp(argv[i], "--debug_leveld")) {
            log_messages.set_debug_level(atoi(argv[++i]));
        } else if (!strcmp(argv[i], "--sleep_time")) {
            sleep_time = atoi(argv[++i]);
        } else if (!strcmp(argv[i], "--random_order")) {
            order_clause = " order by random ";
        } else if (!strcmp(argv[i], "--priority_asc")) {
            order_clause = " order by priority asc ";
        } else if (!strcmp(argv[i], "--priority_order")) {
            order_clause = " order by priority desc ";
        } else if (!strcmp(argv[i], "--priority_order_create_time")) {
            order_clause = " order by priority desc, workunitid ";
        } else {
            usage();
        }
    }
    if (!app_name || !lo || !hi || !sleep_time) {
        usage();
    }

    log_messages.printf(MSG_NORMAL, "Starting\n");

    retval = config.parse_file();
    if (retval) {
        log_messages.printf(MSG_CRITICAL,
            "Can't parse config.xml: %s\n", boincerror(retval)
        );
        exit(1);
    }

    retval = boinc_db.open(
        config.db_name, config.db_host, config.db_user, config.db_passwd
    );
    if (retval) {
        log_messages.printf(MSG_CRITICAL,
            "boinc_db.open: %d; %s\n", retval, boinc_db.error_string()
        );
        exit(1);
    }

    sprintf(buf, "where name='%s'", app_name);
    if (app.lookup(buf)) {
        log_messages.printf(MSG_CRITICAL, "no such app: %s\n", app_name);
        exit(1);
    }
    if (app.n_size_classes < 2) {
        log_messages.printf(MSG_CRITICAL, "app '%s' is not multi-size\n", app_name);
        exit(1);
    }
    while (1) {
        bool action;
        retval = do_pass(action);
        if (retval) {
            log_messages.printf(MSG_CRITICAL,
                "do_pass(): %s", boincerror(retval)
            );
            exit(1);
        }
        if (!action) {
            log_messages.printf(MSG_NORMAL, "sleeping\n");
            daemon_sleep(sleep_time);
        }
    }
}
开发者ID:AltroCoin,项目名称:altrocoin,代码行数:77,代码来源:size_regulator.cpp

示例15: main

int main(int argc, char** argv) {
    int i, retval;
    char buf[256];

    for (i=1; i<argc; i++) {
        if (is_arg(argv[i], "d")) {
            if (!argv[++i]) {
                log_messages.printf(MSG_CRITICAL, "%s requires an argument\n\n", argv[--i]);
                usage(argv[0]);
                exit(1);
            }
            int dl = atoi(argv[i]);
            log_messages.set_debug_level(dl);
            if (dl == 4) g_print_queries = true;
        } else if (!strcmp(argv[i], "--app")) {
            app_name = argv[++i];
        } else if (!strcmp(argv[i], "--in_template_file")) {
            in_template_file = argv[++i];
        } else if (!strcmp(argv[i], "--out_template_file")) {
            out_template_file = argv[++i];
        } else if (is_arg(argv[i], "h") || is_arg(argv[i], "help")) {
            usage(argv[0]);
            exit(0);
        } else if (is_arg(argv[i], "v") || is_arg(argv[i], "version")) {
            printf("%s\n", SVN_VERSION);
            exit(0);
        } else {
            log_messages.printf(MSG_CRITICAL, "unknown command line argument: %s\n\n", argv[i]);
            usage(argv[0]);
            exit(1);
        }
    }

    retval = config.parse_file();
    if (retval) {
        log_messages.printf(MSG_CRITICAL,
            "Can't parse config.xml: %s\n", boincerror(retval)
        );
        exit(1);
    }

    retval = boinc_db.open(
        config.db_name, config.db_host, config.db_user, config.db_passwd
    );
    if (retval) {
        log_messages.printf(MSG_CRITICAL, "can't open db\n");
        exit(1);
    }

    sprintf(buf, "where name='%s'", app_name);
    if (app.lookup(buf)) {
        log_messages.printf(MSG_CRITICAL, "can't find app %s\n", app_name);
        exit(1);
    }

    sprintf(buf, "templates/%s", in_template_file);
    if (read_file_malloc(config.project_path(buf), in_template)) {
        log_messages.printf(MSG_CRITICAL, "can't read input template %s\n", buf);
        exit(1);
    }

    start_time = time(0);
    seqno = 0;

    log_messages.printf(MSG_NORMAL, "Starting\n");

    main_loop();
}
开发者ID:WilliamStilte,项目名称:boinc,代码行数:68,代码来源:sample_work_generator.cpp


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