~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to sched/server_types.h

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// This file is part of BOINC.
2
 
// http://boinc.berkeley.edu
3
 
// Copyright (C) 2008 University of California
4
 
//
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.
9
 
//
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.
14
 
//
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/>.
17
 
 
18
 
#ifndef _SERVER_TYPES_
19
 
#define _SERVER_TYPES_
20
 
 
21
 
#include <cstdio>
22
 
#include <vector>
23
 
 
24
 
#include "boinc_db.h"
25
 
#include "common_defs.h"
26
 
#include "md5_file.h"
27
 
#include "coproc.h"
28
 
 
29
 
#include "edf_sim.h"
30
 
 
31
 
// for projects that support work filtering by app,
32
 
// this records an app for which the user will accept work
33
 
//
34
 
struct APP_INFO {
35
 
        int appid;
36
 
        int work_available;
37
 
};
38
 
 
39
 
// Details concerning a host
40
 
//
41
 
struct HOST_INFO {
42
 
        bool allow_non_preferred_apps;
43
 
        bool allow_beta_work;
44
 
        bool reliable;
45
 
        std::vector<APP_INFO> preferred_apps;
46
 
};
47
 
 
48
 
// represents a resource (disk etc.) that the client may not have enough of
49
 
//
50
 
struct RESOURCE {
51
 
    bool insufficient;
52
 
    double needed;      // the min extra amount needed
53
 
 
54
 
    inline void set_insufficient(double x) {
55
 
        insufficient = true;
56
 
        if (needed) {
57
 
            if (x < needed) needed = x;
58
 
        } else {
59
 
            needed = x;
60
 
        }
61
 
    }
62
 
};
63
 
 
64
 
// message intended for human eyes
65
 
//
66
 
struct USER_MESSAGE {
67
 
    std::string message;
68
 
    std::string priority;
69
 
    USER_MESSAGE(const char* m, const char*p);
70
 
};
71
 
 
72
 
struct HOST_USAGE {
73
 
    COPROCS coprocs;
74
 
    double avg_ncpus;
75
 
    double max_ncpus;
76
 
    double flops;
77
 
    char cmdline[256];
78
 
 
79
 
 
80
 
    HOST_USAGE() {
81
 
        coprocs.coprocs.clear();
82
 
        avg_ncpus = 1;
83
 
        max_ncpus = 1;
84
 
        flops = 0;
85
 
        strcpy(cmdline, "");
86
 
    }
87
 
    void sequential_app(double x) {
88
 
        coprocs.coprocs.clear();
89
 
        avg_ncpus = 1;
90
 
        max_ncpus = 1;
91
 
        flops = x;
92
 
        strcpy(cmdline, "");
93
 
    }
94
 
    ~HOST_USAGE(){}
95
 
};
96
 
 
97
 
// keep track of the best app_version for each app for this host
98
 
//
99
 
struct BEST_APP_VERSION {
100
 
    int appid;
101
 
    APP_VERSION* avp;       // NULL if none exists
102
 
    HOST_USAGE host_usage;
103
 
};
104
 
 
105
 
// summary of a client's request for work, and our response to it
106
 
// Note: this is zeroed out in SCHEDULER_REPLY constructor
107
 
//
108
 
struct WORK_REQ {
109
 
    bool infeasible_only;
110
 
    bool reliable_only;
111
 
    bool user_apps_only;
112
 
    bool beta_only;
113
 
        // The above are used by old-style (non-score-based) scheduling
114
 
 
115
 
    HOST_INFO host_info;
116
 
    double seconds_to_fill;
117
 
                // in "normalized CPU seconds"; see
118
 
        // http://boinc.berkeley.edu/trac/wiki/ClientSched#NormalizedCPUTime
119
 
    double disk_available;
120
 
    int nresults;
121
 
    double running_frac;
122
 
    bool trust;     // allow unreplicated jobs to be sent
123
 
 
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.
127
 
    //
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;
135
 
        } else {
136
 
            edf_reject_min_cpu = cpu;
137
 
            edf_reject_max_delay_bound = delay_bound;
138
 
            have_edf_reject = true;
139
 
        }
140
 
    }
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;
145
 
        return true;
146
 
    }
147
 
 
148
 
    RESOURCE disk;
149
 
    RESOURCE mem;
150
 
    RESOURCE speed;
151
 
    RESOURCE bandwidth;
152
 
 
153
 
    std::vector<USER_MESSAGE> no_work_messages;
154
 
    std::vector<BEST_APP_VERSION*> best_app_versions;
155
 
 
156
 
    bool no_allowed_apps_available;
157
 
    bool excessive_work_buf;
158
 
    bool no_app_version;
159
 
    bool hr_reject_temp;
160
 
    bool hr_reject_perm;
161
 
    bool outdated_core;
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&);
176
 
};
177
 
 
178
 
// a description of a sticky file on host.
179
 
//
180
 
struct FILE_INFO {
181
 
    char name[256];
182
 
 
183
 
    int parse(FILE*);
184
 
};
185
 
 
186
 
struct MSG_FROM_HOST_DESC {
187
 
    char variety[256];
188
 
    std::string msg_text;
189
 
    int parse(FILE*);
190
 
};
191
 
 
192
 
// an app version from an anonymous-platform client
193
 
//
194
 
struct CLIENT_APP_VERSION {
195
 
    char app_name[256];
196
 
    int version_num;
197
 
 
198
 
    int parse(FILE*);
199
 
};
200
 
 
201
 
// subset of global prefs used by scheduler
202
 
//
203
 
struct GLOBAL_PREFS {
204
 
    double mod_time;
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;
212
 
 
213
 
    void parse(const char* buf, const char* venue);
214
 
    void defaults();
215
 
    inline double work_buf_min() {return work_buf_min_days*86400;}
216
 
};
217
 
 
218
 
struct GUI_URLS {
219
 
    char* text;
220
 
    void init();
221
 
    void get_gui_urls(USER& user, HOST& host, TEAM& team, char*);
222
 
};
223
 
 
224
 
struct PROJECT_FILES {
225
 
    char* text;
226
 
    void init();
227
 
};
228
 
 
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
233
 
//
234
 
struct OTHER_RESULT {
235
 
    std::string name;
236
 
    bool abort;
237
 
    bool abort_if_not_started;
238
 
    int reason;     // see codes below
239
 
 
240
 
    int parse(FILE*);
241
 
};
242
 
 
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
247
 
 
248
 
struct CLIENT_PLATFORM {
249
 
    char name[256];
250
 
    int parse(FILE*);
251
 
};
252
 
 
253
 
struct PLATFORM_LIST {
254
 
    std::vector<PLATFORM*> list;
255
 
};
256
 
 
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
268
 
    int rpc_seqno;
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
273
 
    double rrs_fraction;
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];
284
 
 
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];
289
 
 
290
 
    HOST host;      // request message is parsed into here.
291
 
                    // does NOT contain the full host record.
292
 
    COPROCS coprocs;
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
311
 
 
312
 
    SCHEDULER_REQUEST();
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
317
 
};
318
 
 
319
 
// keep track of bottleneck disk preference
320
 
//
321
 
struct DISK_LIMITS {
322
 
    double max_used;
323
 
    double max_frac;
324
 
    double min_free;
325
 
};
326
 
 
327
 
// NOTE: if any field requires initialization,
328
 
// you must do it in the constructor.  Nothing is zeroed by default.
329
 
//
330
 
struct SCHEDULER_REPLY {
331
 
    WORK_REQ wreq;
332
 
    DISK_LIMITS disk_limits;
333
 
    double request_delay;       // don't request again until this time elapses
334
 
    std::vector<USER_MESSAGE> messages;
335
 
    int hostid;
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
341
 
    USER user;
342
 
    char email_hash[MD5_LEN];
343
 
    HOST host;                  // after validation, contains full host rec
344
 
    TEAM team;
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];
356
 
    bool send_msg_ack;
357
 
    bool project_is_down;
358
 
 
359
 
    SCHEDULER_REPLY();
360
 
    ~SCHEDULER_REPLY();
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
370
 
};
371
 
 
372
 
#endif