本文整理汇总了C++中DB_APP::lookup方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_APP::lookup方法的具体用法?C++ DB_APP::lookup怎么用?C++ DB_APP::lookup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_APP
的用法示例。
在下文中一共展示了DB_APP::lookup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: main
//.........这里部分代码省略.........
} 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);
}
retval = boinc_db.set_isolation_level(READ_UNCOMMITTED);
if (retval) {
log_messages.printf(MSG_CRITICAL,
"boinc_db.set_isolation_level: %s; %s\n",
boincerror(retval), boinc_db.error_string()
);
}
if (*app.name && !appid) {
char buf[256];
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);
}
appid=app.id;
log_messages.printf(MSG_DEBUG, "Deleting files of appid %d\n",appid);
}
install_stop_signal_handler();
bool retry_errors_now = !dont_retry_errors;
double next_error_time=0;
double next_antique_time = dtime() + antique_delay;
while (1) {
bool got_any = do_pass(false);
if (retry_errors_now) {
bool got_any_errors = do_pass(true);
if (got_any_errors) {
got_any = true;
} else {
retry_errors_now = false;
next_error_time = dtime() + ERROR_INTERVAL;
log_messages.printf(MSG_DEBUG,
"ending retry of previous errors\n"
);
}
}
if (!got_any) {
if (one_pass) break;
sleep(sleep_interval);
}
if (!dont_delete_antiques && (dtime() > next_antique_time)) {
log_messages.printf(MSG_DEBUG,
"Doing antique deletion pass\n"
);
do_antique_pass();
next_antique_time = dtime() + antique_interval;
}
if (!dont_retry_errors && !retry_errors_now && (dtime() > next_error_time)) {
retry_errors_now = true;
log_messages.printf(MSG_DEBUG,
"starting retry of previous errors\n"
);
}
}
}
示例4: main
//.........这里部分代码省略.........
} else if (arg(argv, i, "assign_team_all")) {
assign_flag = true;
assign_type = ASSIGN_TEAM;
assign_multi = true;
assign_id = atoi(argv[++i]);
} else {
if (!strncmp("-", argv[i], 1)) {
fprintf(stderr, "create_work: bad argument '%s'\n", argv[i]);
exit(1);
}
infiles = argv+i;
ninfiles = argc - i;
break;
}
i++;
}
#define CHKARG(x,m) do { if (!(x)) { fprintf(stderr, "create_work: bad command line: "m"\n"); exit(1); } } while (0)
#define CHKARG_STR(v,m) CHKARG(strlen(v),m)
CHKARG_STR(app.name , "need --appname");
CHKARG_STR(wu.name , "need --wu_name");
CHKARG_STR(wu_template_file , "need --wu_template");
CHKARG_STR(result_template_file , "need --result_template");
#undef CHKARG
#undef CHKARG_STR
if (assign_flag) {
if (!strstr(wu.name, ASSIGNED_WU_STR)) {
fprintf(stderr,
"Assigned WU names must contain '%s'\n", ASSIGNED_WU_STR
);
exit(1);
}
}
retval = config.parse_file();
if (retval) {
fprintf(stderr, "Can't parse config file: %d\n", retval);
exit(1);
} else {
strcpy(db_name, config.db_name);
strcpy(db_passwd, config.db_passwd);
strcpy(db_user, config.db_user);
strcpy(db_host, config.db_host);
strcpy(download_dir, config.download_dir);
}
retval = boinc_db.open(db_name, db_host, db_user, db_passwd);
if (retval) {
fprintf(stderr, "create_work: error opening database: %d\n", retval );
exit(1);
}
sprintf(buf, "where name='%s'", app.name);
retval = app.lookup(buf);
if (retval) {
fprintf(stderr, "create_work: app not found\n");
exit(1);
}
retval = read_filename(wu_template_file, wu_template, sizeof(wu_template));
if (retval) {
fprintf(stderr, "create_work: can't open WU template: %d\n", retval);
exit(1);
}
wu.appid = app.id;
strcpy(result_template_path, "./");
strcat(result_template_path, result_template_file);
retval = create_work(
wu,
wu_template,
result_template_file,
result_template_path,
const_cast<const char **>(infiles),
ninfiles,
config,
command_line,
additional_xml
);
if (retval) {
fprintf(stderr, "create_work: %d\n", retval);
exit(1);
}
if (assign_flag) {
DB_ASSIGNMENT assignment;
assignment.clear();
assignment.create_time = time(0);
assignment.target_id = assign_id;
assignment.target_type = assign_type;
assignment.multi = assign_multi;
assignment.workunitid = wu.id;
retval = assignment.insert();
if (retval) {
fprintf(stderr, "assignment.insert() failed: %d\n", retval);
exit(1);
}
}
boinc_db.close();
}
示例5: 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);
}
示例6: main
//.........这里部分代码省略.........
usage();
}
if (!strlen(jd.wu.name)) {
sprintf(jd.wu.name, "%s_%d_%f", app.name, getpid(), dtime());
}
if (!strlen(jd.wu_template_file)) {
sprintf(jd.wu_template_file, "templates/%s_in", app.name);
}
if (!strlen(jd.result_template_file)) {
sprintf(jd.result_template_file, "templates/%s_out", app.name);
}
retval = config.parse_file(config_dir);
if (retval) {
fprintf(stderr, "Can't parse config file: %s\n", boincerror(retval));
exit(1);
} else {
strcpy(db_name, config.db_name);
strcpy(db_passwd, config.db_passwd);
strcpy(db_user, config.db_user);
strcpy(db_host, config.db_host);
strcpy(download_dir, config.download_dir);
}
retval = boinc_db.open(db_name, db_host, db_user, db_passwd);
if (retval) {
fprintf(stderr,
"create_work: error opening database: %s\n", boincerror(retval)
);
exit(1);
}
boinc_db.set_isolation_level(READ_UNCOMMITTED);
sprintf(buf, "where name='%s'", app.name);
retval = app.lookup(buf);
if (retval) {
fprintf(stderr, "create_work: app not found\n");
exit(1);
}
// read the WU template file.
// this won't get used if we're creating a batch
// with job-level WU templates
//
if (boinc_file_exists(jd.wu_template_file)) {
retval = read_filename(
jd.wu_template_file, jd.wu_template, sizeof(jd.wu_template)
);
if (retval) {
fprintf(stderr,
"create_work: can't open input template %s\n", jd.wu_template_file
);
exit(1);
}
}
jd.wu.appid = app.id;
strcpy(jd.result_template_path, "./");
strcat(jd.result_template_path, jd.result_template_file);
if (use_stdin) {
// clear the WU template name so we'll recognize a job-level one
//
strcpy(jd.wu_template_file, "");
if (jd.assign_flag) {
示例7: 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);
}
}
}
示例8: 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();
}
示例9: 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");
//.........这里部分代码省略.........
示例10: 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);
}
示例11: 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);
//.........这里部分代码省略.........
示例12: main
//.........这里部分代码省略.........
usage();
}
if (!strlen(jd.wu.name)) {
sprintf(jd.wu.name, "%s_%d_%f", app.name, getpid(), dtime());
}
if (!strlen(wu_template_file)) {
sprintf(wu_template_file, "templates/%s_in", app.name);
}
if (!strlen(jd.result_template_file)) {
sprintf(jd.result_template_file, "templates/%s_out", app.name);
}
retval = config.parse_file(config_dir);
if (retval) {
fprintf(stderr, "Can't parse config file: %s\n", boincerror(retval));
exit(1);
} else {
strcpy(db_name, config.db_name);
strcpy(db_passwd, config.db_passwd);
strcpy(db_user, config.db_user);
strcpy(db_host, config.db_host);
strcpy(download_dir, config.download_dir);
}
retval = boinc_db.open(db_name, db_host, db_user, db_passwd);
if (retval) {
fprintf(stderr,
"create_work: error opening database: %s\n", boincerror(retval)
);
exit(1);
}
boinc_db.set_isolation_level(READ_UNCOMMITTED);
sprintf(buf, "where name='%s'", app.name);
retval = app.lookup(buf);
if (retval) {
fprintf(stderr, "create_work: app not found\n");
exit(1);
}
retval = read_filename(
wu_template_file, jd.wu_template, sizeof(jd.wu_template)
);
if (retval) {
fprintf(stderr,
"create_work: can't open input template %s\n", wu_template_file
);
exit(1);
}
jd.wu.appid = app.id;
strcpy(jd.result_template_path, "./");
strcat(jd.result_template_path, jd.result_template_file);
if (use_stdin) {
string values;
DB_WORKUNIT wu;
int _argc;
char* _argv[100], value_buf[MAX_QUERY_LEN];
for (int j=0; ; j++) {
char* p = fgets(buf, sizeof(buf), stdin);
if (p == NULL) break;
JOB_DESC jd2 = jd;
strcpy(jd2.wu.name, "");
_argc = parse_command_line(buf, _argv);
jd2.parse_cmdline(_argc, _argv);
if (!strlen(jd2.wu.name)) {
示例13: 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);
}
示例14: main
int main(int argc, char** argv) {
int i, retval;
char buf[256];
if (!GetCurrentDir(cCurrentPath, sizeof(cCurrentPath)))
{
return 0;
}
cCurrentPath[sizeof(cCurrentPath) - 1] = '\0'; /* not really required */
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);
log_messages.printf(MSG_NORMAL, "Starting\n");
get_graphs();
if(n1==n2)
main_loop();
else{
FILE *result = fopen("result.txt","w");
fprintf(result,"NOT ISOMORPHIC");
fclose(result);
}
//deleting memory allocated for arrays
}
示例15: main
//.........这里部分代码省略.........
log_messages.printf(MSG_CRITICAL, "%s requires an argument\n\n", argv[--i]);
usage(argv[0]);
exit(1);
}
sleep_sec = atoi(argv[i]);
if (sleep_sec < 1 || sleep_sec > 86400) {
log_messages.printf(MSG_CRITICAL,
"Unreasonable value of sleep interval: %d seconds\n",
sleep_sec
);
usage(argv[0]);
exit(1);
}
} else if (is_arg(argv[i], "--help") || is_arg(argv[i], "-help") || is_arg(argv[i], "-h")) {
usage(argv[0]);
return 0;
} else if (is_arg(argv[i], "--version") || is_arg(argv[i], "-version")) {
printf("%s\n", SVN_VERSION);
exit(0);
} 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], "app")) {
safe_strcpy(app_name, argv[++i]);
} else {
log_messages.printf(MSG_CRITICAL,
"unknown command line argument: %s\n\n", argv[i]
);
usage(argv[0]);
exit(1);
}
}
if (id_modulus && !no_archive) {
log_messages.printf(MSG_CRITICAL,
"If you use modulus, you must set no_archive\n\n"
);
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);
}
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(2);
}
install_stop_signal_handler();
boinc_mkdir(config.project_path("archives"));
// on exit, either via the check_stop_daemons signal handler, or
// through a regular call to exit, these functions will be called
// in the opposite order of registration.
//
atexit(close_db_exit_handler);
atexit(close_all_archives);
if (strlen(app_name)) {
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) {
if (time_to_quit()) {
break;
}
if (!do_pass() && !one_pass) {
log_messages.printf(MSG_NORMAL, "Sleeping....\n");
daemon_sleep(sleep_sec);
}
if (one_pass) {
break;
}
}
// files and database are closed by exit handler
exit(0);
}