~ubuntu-branches/ubuntu/lucid/boinc/lucid

« back to all changes in this revision

Viewing changes to sched/sample_work_generator.C

  • Committer: Bazaar Package Importer
  • Author(s): Frank S. Thomas, Frank S. Thomas
  • Date: 2008-05-31 08:02:47 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20080531080247-4ce890lp2rc768cr
Tags: 6.2.7-1
[ Frank S. Thomas ]
* New upstream release.
  - BOINC Manager: Redraw disk usage charts immediately after connecting to
    a (different) client. (closes: 463823)
* debian/copyright:
  - Added the instructions from debian/README.Debian-source about how
    repackaged BOINC tarballs can be reproduced because DevRef now
    recommends to put this here instead of in the afore-mentioned file.
  - Updated for the new release.
* Removed the obsolete debian/README.Debian-source.
* For consistency upstream renamed the core client and the command tool
  ("boinc_client" to "boinc" and "boinc_cmd" to "boinccmd"). Done the same
  in all packages and created symlinks with the old names for the binaries
  and man pages. Also added an entry in debian/boinc-client.NEWS explaining
  this change.
* debian/rules: Do not list Makefile.ins in the clean target individually,
  just remove all that can be found.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
// To view the GNU Lesser General Public License visit
16
16
// http://www.gnu.org/copyleft/lesser.html
17
17
// or write to the Free Software Foundation, Inc.,
18
 
// 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 
20
20
// sample_work_generator.C: an example BOINC work generator.
21
21
// This work generator has the following properties
29
29
//   the file (and the workunit names) contain a timestamp
30
30
//   and sequence number, so that they're unique.
31
31
 
 
32
#include <unistd.h>
 
33
#include <cstdlib>
 
34
#include <string>
 
35
#include <cstring>
 
36
 
32
37
#include "boinc_db.h"
33
38
#include "error_numbers.h"
34
39
#include "backend_lib.h"
49
54
DB_APP app;
50
55
int start_time;
51
56
int seqno;
52
 
SCHED_CONFIG config;
53
57
 
54
58
// create one new job
55
59
//
56
60
int make_job() {
57
61
    DB_WORKUNIT wu;
58
 
    char name[256], path[256], buf[256];
 
62
    char name[256], path[256];
59
63
    const char* infiles[1];
60
64
    int retval;
61
65
 
109
113
    while (1) {
110
114
        check_stop_daemons();
111
115
        int n;
112
 
        retval = count_unsent_results(n);
 
116
        retval = count_unsent_results(n, 0);
113
117
        if (n > CUSHION) {
114
118
            sleep(60);
115
119
        } else {
116
120
            int njobs = (CUSHION-n)/REPLICATION_FACTOR;
117
 
            log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG,
 
121
            log_messages.printf(MSG_DEBUG,
118
122
                "Making %d jobs\n", njobs
119
123
            );
120
124
            for (int i=0; i<njobs; i++) {
121
125
                retval = make_job();
122
126
                if (retval) {
123
 
                    log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,
 
127
                    log_messages.printf(MSG_CRITICAL,
124
128
                        "can't make job: %d\n", retval
125
129
                    );
126
130
                    exit(retval);
141
145
        if (!strcmp(argv[i], "-d")) {
142
146
            log_messages.set_debug_level(atoi(argv[++i]));
143
147
        } else {
144
 
            log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,
 
148
            log_messages.printf(MSG_CRITICAL,
145
149
                "bad cmdline arg: %s", argv[i]
146
150
            );
147
151
        }
148
152
    }
149
153
 
150
154
    if (config.parse_file("..")) {
151
 
        log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,
 
155
        log_messages.printf(MSG_CRITICAL,
152
156
            "can't read config file\n"
153
157
        );
154
158
        exit(1);
158
162
        config.db_name, config.db_host, config.db_user, config.db_passwd
159
163
    );
160
164
    if (retval) {
161
 
        log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL, "can't open db\n");
 
165
        log_messages.printf(MSG_CRITICAL, "can't open db\n");
162
166
        exit(1);
163
167
    }
164
168
    if (app.lookup("where name='uppercase'")) {
165
 
        log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL, "can't find app\n");
 
169
        log_messages.printf(MSG_CRITICAL, "can't find app\n");
166
170
        exit(1);
167
171
    }
168
172
    if (read_file_malloc("../templates/uc_wu", wu_template)) {
169
 
        log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL, "can't read WU template\n");
 
173
        log_messages.printf(MSG_CRITICAL, "can't read WU template\n");
170
174
        exit(1);
171
175
    }
172
176
 
173
177
    start_time = time(0);
174
178
    seqno = 0;
175
179
 
176
 
    log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL, "Starting\n");
 
180
    log_messages.printf(MSG_NORMAL, "Starting\n");
177
181
 
178
182
    main_loop();
179
183
}