1
// This file is part of BOINC.
2
// http://boinc.berkeley.edu
3
// Copyright (C) 2008 University of California
5
// BOINC is free software; you can redistribute it and/or modify it
6
// under the terms of the GNU Lesser General Public License
7
// as published by the Free Software Foundation,
8
// either version 3 of the License, or (at your option) any later version.
10
// BOINC is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
// See the GNU Lesser General Public License for more details.
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
18
#ifndef _SERVER_TYPES_
19
#define _SERVER_TYPES_
25
#include "common_defs.h"
31
// for projects that support work filtering by app,
32
// this records an app for which the user will accept work
39
// Details concerning a host
42
bool allow_non_preferred_apps;
45
std::vector<APP_INFO> preferred_apps;
48
// represents a resource (disk etc.) that the client may not have enough of
52
double needed; // the min extra amount needed
54
inline void set_insufficient(double x) {
57
if (x < needed) needed = x;
64
// message intended for human eyes
69
USER_MESSAGE(const char* m, const char*p);
81
coprocs.coprocs.clear();
87
void sequential_app(double x) {
88
coprocs.coprocs.clear();
97
// keep track of the best app_version for each app for this host
99
struct BEST_APP_VERSION {
101
APP_VERSION* avp; // NULL if none exists
102
HOST_USAGE host_usage;
105
// summary of a client's request for work, and our response to it
106
// Note: this is zeroed out in SCHEDULER_REPLY constructor
109
bool infeasible_only;
113
// The above are used by old-style (non-score-based) scheduling
116
double seconds_to_fill;
117
// in "normalized CPU seconds"; see
118
// http://boinc.berkeley.edu/trac/wiki/ClientSched#NormalizedCPUTime
119
double disk_available;
122
bool trust; // allow unreplicated jobs to be sent
124
// The following keep track of the "easiest" job that was rejected
125
// by EDF simulation.
126
// Any jobs harder than this can be rejected without doing the simulation.
128
double edf_reject_min_cpu;
129
int edf_reject_max_delay_bound;
130
bool have_edf_reject;
131
void edf_reject(double cpu, int delay_bound) {
132
if (have_edf_reject) {
133
if (cpu < edf_reject_min_cpu) edf_reject_min_cpu = cpu;
134
if (delay_bound> edf_reject_max_delay_bound) edf_reject_max_delay_bound = delay_bound;
136
edf_reject_min_cpu = cpu;
137
edf_reject_max_delay_bound = delay_bound;
138
have_edf_reject = true;
141
bool edf_reject_test(double cpu, int delay_bound) {
142
if (!have_edf_reject) return false;
143
if (cpu < edf_reject_min_cpu) return false;
144
if (delay_bound > edf_reject_max_delay_bound) return false;
153
std::vector<USER_MESSAGE> no_work_messages;
154
std::vector<BEST_APP_VERSION*> best_app_versions;
156
bool no_allowed_apps_available;
157
bool excessive_work_buf;
162
bool daily_result_quota_exceeded;
163
int daily_result_quota; // for this machine: number of cpus * daily_quota/cpu
164
bool cache_size_exceeded;
165
bool no_jobs_available; // project has no work right now
166
int nresults_on_host;
167
// How many results from this project are in progress on the host.
168
// Initially this is the number of "other_results"
169
// reported in the request message.
170
// If the resend_lost_results option is used,
171
// it's set to the number of outstanding results taken from the DB
172
// (those that were lost are resent).
173
// As new results are sent, it's incremented.
174
void update_for_result(double seconds_filled);
175
void insert_no_work_message(USER_MESSAGE&);
178
// a description of a sticky file on host.
186
struct MSG_FROM_HOST_DESC {
188
std::string msg_text;
192
// an app version from an anonymous-platform client
194
struct CLIENT_APP_VERSION {
201
// subset of global prefs used by scheduler
203
struct GLOBAL_PREFS {
205
double disk_max_used_gb;
206
double disk_max_used_pct;
207
double disk_min_free_gb;
208
double work_buf_min_days;
209
double ram_max_used_busy_frac;
210
double ram_max_used_idle_frac;
211
double max_ncpus_pct;
213
void parse(const char* buf, const char* venue);
215
inline double work_buf_min() {return work_buf_min_days*86400;}
221
void get_gui_urls(USER& user, HOST& host, TEAM& team, char*);
224
struct PROJECT_FILES {
229
// Represents a result from this project that the client has.
230
// The request message has a list of these.
231
// The reply message may include a list of those to be aborted
232
// or aborted if not started
234
struct OTHER_RESULT {
237
bool abort_if_not_started;
238
int reason; // see codes below
243
#define ABORT_REASON_NOT_FOUND 1
244
#define ABORT_REASON_WU_CANCELLED 2
245
#define ABORT_REASON_ASSIMILATED 3
246
#define ABORT_REASON_TIMED_OUT 4
248
struct CLIENT_PLATFORM {
253
struct PLATFORM_LIST {
254
std::vector<PLATFORM*> list;
257
struct SCHEDULER_REQUEST {
258
char authenticator[256];
259
CLIENT_PLATFORM platform;
260
std::vector<CLIENT_PLATFORM> alt_platforms;
261
PLATFORM_LIST platforms;
262
char cross_project_id[256];
263
int hostid; // zero if first RPC
264
int core_client_major_version;
265
int core_client_minor_version;
266
int core_client_release;
267
int core_client_version; // 100*major + minor
269
double work_req_seconds;
270
// in "normalized CPU seconds" (see work_req.php)
271
double resource_share_fraction;
272
// this project's fraction of total resource share
274
// ... of runnable resource share
275
double prrs_fraction;
276
// ... of potentially runnable resource share
277
double estimated_delay;
278
// how many wall-clock seconds will elapse before
279
// host will begin any new work for this project
280
double duration_correction_factor;
281
char global_prefs_xml[BLOB_SIZE];
282
char working_global_prefs_xml[BLOB_SIZE];
283
char code_sign_key[4096];
285
bool anonymous_platform;
286
std::vector<CLIENT_APP_VERSION> client_app_versions;
287
GLOBAL_PREFS global_prefs;
288
char global_prefs_source_email_hash[MD5_LEN];
290
HOST host; // request message is parsed into here.
291
// does NOT contain the full host record.
293
std::vector<RESULT> results;
294
// completed results being reported
295
std::vector<MSG_FROM_HOST_DESC> msgs_from_host;
296
std::vector<FILE_INFO> file_infos;
297
// sticky files reported by host for locality scheduling
298
std::vector<FILE_INFO> file_delete_candidates;
299
// sticky files reported by host, deletion candidates
300
std::vector<FILE_INFO> files_not_needed;
301
// sticky files reported by host, no longer needed
302
std::vector<OTHER_RESULT> other_results;
303
// in-progress results from this project
304
std::vector<IP_RESULT> ip_results;
305
// in-progress results from all projects
306
bool have_other_results_list;
307
bool have_ip_results_list;
308
bool have_time_stats_log;
309
bool client_cap_plan_class;
310
int sandbox; // -1 = don't know
313
~SCHEDULER_REQUEST();
314
const char* parse(FILE*);
315
bool has_version(APP& app);
316
int write(FILE*); // write request info to file: not complete
319
// keep track of bottleneck disk preference
327
// NOTE: if any field requires initialization,
328
// you must do it in the constructor. Nothing is zeroed by default.
330
struct SCHEDULER_REPLY {
332
DISK_LIMITS disk_limits;
333
double request_delay; // don't request again until this time elapses
334
std::vector<USER_MESSAGE> messages;
336
// nonzero only if a new host record was created.
337
// this tells client to reset rpc_seqno
338
int lockfile_fd; // file descriptor of lockfile, or -1 if no lock.
339
bool send_global_prefs;
340
bool nucleus_only; // send only message
342
char email_hash[MD5_LEN];
343
HOST host; // after validation, contains full host rec
345
std::vector<APP> apps;
346
std::vector<APP_VERSION> app_versions;
347
std::vector<WORKUNIT>wus;
348
std::vector<RESULT>results;
349
std::vector<std::string>result_acks;
350
std::vector<std::string>result_aborts;
351
std::vector<std::string>result_abort_if_not_starteds;
352
std::vector<MSG_TO_HOST>msgs_to_host;
353
std::vector<FILE_INFO>file_deletes;
354
char code_sign_key[4096];
355
char code_sign_key_signature[4096];
357
bool project_is_down;
361
int write(FILE*, SCHEDULER_REQUEST&);
362
void insert_app_unique(APP&);
363
void insert_app_version_unique(APP_VERSION&);
364
void insert_workunit_unique(WORKUNIT&);
365
void insert_result(RESULT&);
366
void insert_message(USER_MESSAGE&);
367
void set_delay(double);
368
void got_good_result(); // adjust max_results_day
369
void got_bad_result(); // adjust max_results_day