/usr/include/boinc/boinc_db.h is in libboinc-app-dev 7.2.42+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | // This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
#ifndef _BOINC_DB_
#define _BOINC_DB_
// Structures corresponding to database records.
// Some of these types have counterparts in client/types.h,
// but don't be deceived - client and server have different variants.
// The parse and write functions are for use in scheduler RPC.
// They don't necessarily serialize the entire records.
#include <cstdio>
#include <vector>
#include <string.h>
#include "db_base.h"
#include "boinc_db_types.h"
extern DB_CONN boinc_db;
struct TRANSITIONER_ITEM {
int id; // WARNING: this is the WU ID
char name[256];
int appid;
int min_quorum;
bool need_validate;
int canonical_resultid;
int transition_time;
int delay_bound;
int error_mask;
int max_error_results;
int max_total_results;
int file_delete_state;
int assimilate_state;
int target_nresults;
char result_template_file[64];
int priority;
int hr_class;
int batch;
int app_version_id;
int transitioner_flags;
int size_class;
int res_id; // This is the RESULT ID
char res_name[256];
int res_report_deadline;
int res_server_state;
int res_outcome;
int res_validate_state;
int res_file_delete_state;
int res_sent_time;
int res_hostid;
int res_received_time;
int res_app_version_id;
void clear();
void parse(MYSQL_ROW&);
};
struct DB_HOST_APP_VERSION : public DB_BASE, public HOST_APP_VERSION {
DB_HOST_APP_VERSION(DB_CONN* p=0);
void db_print(char*);
void db_parse(MYSQL_ROW &row);
int update_scheduler(DB_HOST_APP_VERSION&);
int update_validator(DB_HOST_APP_VERSION&);
};
struct DB_USER_SUBMIT : public DB_BASE, public USER_SUBMIT {
DB_USER_SUBMIT(DB_CONN* p=0);
void db_print(char*);
void db_parse(MYSQL_ROW &row);
};
struct STATE_COUNTS {
int appid;
int last_update_time;
int result_server_state_2;
int result_server_state_4;
int result_file_delete_state_1;
int result_file_delete_state_2;
int result_server_state_5_and_file_delete_state_0;
int workunit_need_validate_1;
int workunit_assimilate_state_1;
int workunit_file_delete_state_1;
int workunit_file_delete_state_2;
void clear();
};
struct DB_STATE_COUNTS : public DB_BASE, public STATE_COUNTS {
DB_STATE_COUNTS(DB_CONN* p=0);
int get_id();
void db_print(char *);
void db_parse(MYSQL_ROW &row);
};
struct VALIDATOR_ITEM {
WORKUNIT wu;
RESULT res;
void clear();
void parse(MYSQL_ROW&);
};
class DB_PLATFORM : public DB_BASE, public PLATFORM {
public:
DB_PLATFORM(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
};
class DB_APP : public DB_BASE, public APP {
public:
DB_APP(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
};
class DB_APP_VERSION : public DB_BASE, public APP_VERSION {
public:
DB_APP_VERSION(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
void operator=(APP_VERSION& w) {APP_VERSION::operator=(w);}
};
class DB_USER : public DB_BASE, public USER {
public:
DB_USER(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
void operator=(USER& r) {USER::operator=(r);}
};
class DB_TEAM : public DB_BASE, public TEAM {
public:
DB_TEAM(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
};
class DB_HOST : public DB_BASE, public HOST {
public:
DB_HOST(DB_CONN* p=0);
int get_id();
int update_diff_sched(HOST&);
int update_diff_validator(HOST&);
int fpops_percentile(double percentile, double& fpops);
// return the given percentile of p_fpops
int fpops_mean(double& mean);
int fpops_stddev(double& stddev);
void db_print(char*);
void db_parse(MYSQL_ROW &row);
void operator=(HOST& r) {HOST::operator=(r);}
};
class DB_RESULT : public DB_BASE, public RESULT {
public:
DB_RESULT(DB_CONN* p=0);
int get_id();
int mark_as_sent(int old_server_state, int report_grace_period);
void db_print(char*);
void db_print_values(char*);
void db_parse(MYSQL_ROW &row);
void operator=(RESULT& r) {RESULT::operator=(r);}
int get_unsent_counts(APP&, int* unsent);
int make_unsent(
APP&, int size_class, int n, const char* order_clause, int& nchanged
);
};
class DB_WORKUNIT : public DB_BASE, public WORKUNIT {
public:
DB_WORKUNIT(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
void operator=(WORKUNIT& w) {WORKUNIT::operator=(w);}
};
class DB_CREDITED_JOB : public DB_BASE, public CREDITED_JOB {
public:
DB_CREDITED_JOB(DB_CONN* p=0);
void db_print(char*);
void db_parse(MYSQL_ROW &row);
void operator=(CREDITED_JOB& wh) {CREDITED_JOB::operator=(wh);}
};
class DB_MSG_FROM_HOST : public DB_BASE, public MSG_FROM_HOST {
public:
DB_MSG_FROM_HOST(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
};
class DB_MSG_TO_HOST : public DB_BASE, public MSG_TO_HOST {
public:
DB_MSG_TO_HOST(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
};
class DB_ASSIGNMENT : public DB_BASE, public ASSIGNMENT {
public:
DB_ASSIGNMENT(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW& row);
};
// The transitioner uses this to get (WU, result) pairs efficiently.
// Each call to enumerate() returns a list of the pairs for a single WU
//
class DB_TRANSITIONER_ITEM_SET : public DB_BASE_SPECIAL {
public:
DB_TRANSITIONER_ITEM_SET(DB_CONN* p=0);
TRANSITIONER_ITEM last_item;
int nitems_this_query;
int enumerate(
int transition_time,
int nresult_limit,
int wu_id_modulus,
int wu_id_remainder,
std::vector<TRANSITIONER_ITEM>& items
);
int update_result(TRANSITIONER_ITEM&);
int update_workunit(TRANSITIONER_ITEM&, TRANSITIONER_ITEM&);
};
// The validator uses this to get (WU, result) pairs efficiently.
// Each call to enumerate() returns a list of the pairs for a single WU
//
class DB_VALIDATOR_ITEM_SET : public DB_BASE_SPECIAL {
public:
DB_VALIDATOR_ITEM_SET(DB_CONN* p=0);
VALIDATOR_ITEM last_item;
int nitems_this_query;
int enumerate(
int appid,
int nresult_limit,
int wu_id_modulus,
int wu_id_remainder,
std::vector<VALIDATOR_ITEM>& items
);
int update_result(RESULT&);
int update_workunit(WORKUNIT&);
};
// used by the feeder and scheduler for outgoing work
//
struct WORK_ITEM {
int res_id;
int res_priority;
int res_server_state;
double res_report_deadline;
WORKUNIT wu;
void parse(MYSQL_ROW& row);
};
class DB_WORK_ITEM : public WORK_ITEM, public DB_BASE_SPECIAL {
int start_id;
// when enumerate_all is used, keeps track of which ID to start from
public:
DB_WORK_ITEM(DB_CONN* p=0);
int enumerate(
int limit, const char* select_clause, const char* order_clause
);
// used by feeder
int enumerate_all(
int limit, const char* select_clause
);
// used by feeder when HR is used.
// Successive calls cycle through all results.
int read_result();
// used by scheduler to read result server state
int update();
// used by scheduler to update WU transition time
// and various result fields
};
// Used by the scheduler to send <result_abort> or <result_abort_if_not_started>
// messages if the result is no longer needed.
//
struct IN_PROGRESS_RESULT {
char result_name[256];
int assimilate_state;
int error_mask;
int server_state;
int outcome;
void parse(MYSQL_ROW& row);
};
class DB_IN_PROGRESS_RESULT : public IN_PROGRESS_RESULT, public DB_BASE_SPECIAL {
public:
DB_IN_PROGRESS_RESULT(DB_CONN* p=0);
int enumerate(int hostid, const char* result_names);
};
// Used by the scheduler to handle results reported by clients
// The read and the update of these results are combined
// into single SQL queries.
struct SCHED_RESULT_ITEM {
char queried_name[256]; // name as reported by client
int id;
char name[256];
int workunitid;
int appid;
int server_state;
int client_state;
int validate_state;
int outcome;
int hostid;
int userid;
int teamid;
int sent_time;
int received_time;
double cpu_time;
char xml_doc_out[BLOB_SIZE];
char stderr_out[BLOB_SIZE];
int app_version_num;
int exit_status;
int file_delete_state;
double elapsed_time;
int app_version_id;
void clear();
void parse(MYSQL_ROW& row);
};
class DB_SCHED_RESULT_ITEM_SET : public DB_BASE_SPECIAL {
public:
DB_SCHED_RESULT_ITEM_SET(DB_CONN* p=0);
std::vector<SCHED_RESULT_ITEM> results;
int add_result(char* result_name);
int enumerate();
// using a single SQL query, look up all the reported results,
// (based on queried_name)
// and fill in the rest of the entries in the results vector
int lookup_result(char* result_name, SCHED_RESULT_ITEM** result);
int update_result(SCHED_RESULT_ITEM& result);
int update_workunits();
};
struct FILE_ITEM {
int id;
char name[254];
char md5sum[34];
double size;
void clear();
};
class DB_FILE : public DB_BASE, public FILE_ITEM {
public:
DB_FILE(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
void operator=(FILE_ITEM& f) {FILE_ITEM::operator=(f);}
};
struct FILESET_ITEM {
int id;
char name[254];
void clear();
};
class DB_FILESET : public DB_BASE, public FILESET_ITEM {
public:
DB_FILESET(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
void operator=(FILESET_ITEM& f) {FILESET_ITEM::operator=(f);}
// retrieve fileset instance (populate object)
int select_by_name(const char* name);
};
struct FILESET_FILE_ITEM {
int fileset_id;
int file_id;
void clear();
};
class DB_FILESET_FILE : public DB_BASE, public FILESET_FILE_ITEM {
public:
DB_FILESET_FILE(DB_CONN* p=0);
void db_print(char*);
void db_parse(MYSQL_ROW &row);
void operator=(FILESET_FILE_ITEM& tf) {FILESET_FILE_ITEM::operator=(tf);}
};
struct SCHED_TRIGGER_ITEM {
int id;
int fileset_id;
bool need_work;
bool work_available;
bool no_work_available;
bool working_set_removal;
void clear();
};
class DB_SCHED_TRIGGER : public DB_BASE, public SCHED_TRIGGER_ITEM {
public:
DB_SCHED_TRIGGER(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
void operator=(SCHED_TRIGGER_ITEM& t) {SCHED_TRIGGER_ITEM::operator=(t);}
typedef enum {
none = 0,
state_need_work = 1,
state_work_available = 2,
state_no_work_available = 3,
state_working_set_removal = 4
} STATE;
// retrieve trigger instance (populate object)
int select_unique_by_fileset_name(const char* fileset_name);
// set single trigger state
int update_single_state(const DB_SCHED_TRIGGER::STATE state, const bool value);
};
struct FILESET_SCHED_TRIGGER_ITEM {
FILESET_ITEM fileset;
SCHED_TRIGGER_ITEM trigger;
void clear();
};
class DB_FILESET_SCHED_TRIGGER_ITEM : public DB_BASE_SPECIAL, public FILESET_SCHED_TRIGGER_ITEM {
public:
DB_FILESET_SCHED_TRIGGER_ITEM(DB_CONN* p=0);
void db_parse(MYSQL_ROW &row);
void operator=(FILESET_SCHED_TRIGGER_ITEM& fst) {FILESET_SCHED_TRIGGER_ITEM::operator=(fst);}
};
class DB_FILESET_SCHED_TRIGGER_ITEM_SET : public DB_BASE_SPECIAL {
public:
DB_FILESET_SCHED_TRIGGER_ITEM_SET(DB_CONN* p=0);
// select available triggers based on name and/or state
// -> name filter optional (set string, default NULL)
// -> pattern search optional (set use_regexp to true, default false))
// -> state filter optional (set state, default none)
// -> state_value (default true)
int select_by_name_state(
const char* fileset_name,
const bool use_regexp,
const DB_SCHED_TRIGGER::STATE state,
const bool state_value);
// check if given trigger (fileset name) is part of set and return position (1-indexed)
int contains_trigger(const char* fileset_name);
// storage vector
std::vector<DB_FILESET_SCHED_TRIGGER_ITEM> items;
};
struct DB_VDA_FILE : public DB_BASE, public VDA_FILE {
DB_VDA_FILE(DB_CONN* p=0);
int get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
};
struct DB_VDA_CHUNK_HOST : public DB_BASE, public VDA_CHUNK_HOST {
DB_VDA_CHUNK_HOST(DB_CONN* p=0);
void db_print(char*);
void db_parse(MYSQL_ROW &row);
};
#endif
|