Skip to content

Commit

Permalink
multiple URLs per file
Browse files Browse the repository at this point in the history
svn path=/trunk/boinc/; revision=108
  • Loading branch information
davidpanderson committed Jun 10, 2002
1 parent 142a50b commit 7d98c6f
Show file tree
Hide file tree
Showing 40 changed files with 617 additions and 280 deletions.
13 changes: 13 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
HIGH-PRIORITY (must be done to support SETI@home)

- Code-signing
research tools for code-signing

- Upload authentication
Each result contains a "certificate", signed with project key, giving
- list of: file name, max size
- min, max times to xfer
modify put program to decrypt certificate, enforce name/size/time limits

- Network retry policies
can't download file: when to give up? how to retry?
exponential backoff
Expand Down Expand Up @@ -142,6 +151,10 @@ LOW-PRIORITY
- test

- implement file upload/download requests
This can be done in the current WU/result paradigm;
WU has a special "null" application
use sticky input files to download;
use upload-when-done output files to upload

- preferences
finish PHP web interface
Expand Down
75 changes: 75 additions & 0 deletions api/api.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <stdio.h>
#include <string.h>

#include "../sched/parse.h"
#include "api.h"

int MFILE::open(char* path, char* mode) {
Expand Down Expand Up @@ -81,3 +82,77 @@ int MFILE::flush() {
len = 0;
return fflush(f);
}

void write_core_file(FILE* f, APP_IN& ai) {
fprintf(f,
"<graphics_xsize>%d</graphics_xsize>\n"
"<graphics_ysize>%d</graphics_ysize>\n"
"<graphics_refresh_period>%f</graphics_refresh_period>\n"
"<checkpoint_period>%f</checkpoint_period>\n"
"<poll_period>%f</poll_period>\n",
ai.graphics.xsize,
ai.graphics.ysize,
ai.graphics.refresh_period,
ai.checkpoint_period,
ai.poll_period
);
}

void parse_core_file(FILE* f, APP_IN& ai) {
char buf[256];

while (fgets(buf, 256, f)) {
if (match_tag(buf, "<app_specific_prefs>")) {
strcpy(ai.app_preferences, "");
while (fgets(buf, 256, f)) {
if (match_tag(buf, "</app_specific_prefs>")) break;
strcat(ai.app_preferences, buf);
}
continue;
}
else if (parse_int(buf, "<graphics_xsize>", ai.graphics.xsize)) continue;
else if (parse_int(buf, "<graphics_ysize>", ai.graphics.ysize)) continue;
else if (parse_double(buf, "<graphics_refresh_period>", ai.graphics.refresh_period)) continue;
else if (parse_double(buf, "<checkpoint_period>", ai.checkpoint_period)) continue;
else if (parse_double(buf, "<poll_period>", ai.poll_period)) continue;
else fprintf(stderr, "read_core_file: unrecognized %s", buf);
}
}

void write_app_file(FILE* f, APP_OUT& ao) {
fprintf(f,
"<percent_done>%f</percent_done>\n"
"<cpu_time_at_checkpoint>%f</cpu_time_at_checkpoint>\n",
ao.percent_done,
ao.cpu_time_at_checkpoint
);
if (ao.checkpointed) {
fprintf(f, "<checkpointed/>\n");
}
}

void parse_app_file(FILE* f, APP_OUT& ao) {
}

void boinc_init(APP_IN& ai) {
FILE* f;

memset(&ai, 0, sizeof(ai));
f = fopen(CORE_TO_APP_FILE, "r");
if (f) {
parse_core_file(f, ai);
unlink(CORE_TO_APP_FILE);
}
}

double boinc_time() {
return double_time();
}

void boinc_poll(APP_IN& ai, APP_OUT& ao) {
FILE* f;

f = fopen("_app_temp", "w");
write_app_file(f, ao);
rename("_app_temp", APP_TO_CORE_FILE);
}
50 changes: 45 additions & 5 deletions api/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
// Contributor(s):
//

#include <stdio.h>

#ifndef BOINC_API
#define BOINC_API

// MFILE supports a primitive form of checkpointing.
// Write all your output (and restart file) to MFILEs.
// The output is buffered in memory.
// Then close all the MFILEs;
// all the buffers will be flushed to disk, almost atomically.

#include <stdio.h>

#ifndef BOINC_API
#define BOINC_API

class MFILE {
char* buf;
int len;
Expand All @@ -42,4 +42,44 @@ class MFILE {
int flush();
};

// An application that wants to be well-behaved should do the following:
//
// - call boinc_init() at startup
// - call boinc_time() periodically.
// This is cheap - it gets the time of day.
// - checkpoint as often as requested by core
// - boinc_poll():
// Call this as often as requested by core

struct APP_IN_GRAPHICS {
int xsize;
int ysize;
double refresh_period;
char shmem_seg_name[32];
};

struct APP_OUT_GRAPHICS {
};

struct APP_IN {
char app_preferences[4096];
APP_IN_GRAPHICS graphics;
double checkpoint_period; // recommended checkpoint period
double poll_period; // recommended poll period
};

struct APP_OUT {
double percent_done;
double cpu_time_at_checkpoint;
bool checkpointed; // true iff checkpointed since last call
};

void boinc_init(APP_IN&);
double boinc_time();
void boinc_poll(APP_IN&, APP_OUT&);
double boinc_cpu_time();

#define CORE_TO_APP_FILE "core_to_app.xml"
#define APP_TO_CORE_FILE "app_to_core.xml"

#endif
45 changes: 45 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -434,3 +434,48 @@ Michael Gary June 08, 2002
server_types.C (added)
server_types.h (added)
show_shmem.C (added)

David A June 9 2002
- added support for multiple URLs in a FILE_INFO
(e.g. multiple servers from which the file can be downloaded)
- started work on "persistent file transfer": a layer on top of
FILE_XFER that manages restarting from failed connections,
and that implements a give-up policy
- added offset arguments to GET and PUT HTTP operations.
NOTE: this will work fine for downloading files (GET)
but we'll have to use something else for upload,
since the standard PUT handler doesn't do offsets,
and we need security functionality in any case.
- added preliminary version of application API for
communicating with core client.
- use <file_ref> tags instead of <input_file> and <output_file>
(makes things simpler)

TODO
notes
api/
api.C,h
client/
configure.in
client_state.C
client_types.C,h
cs_files.C
error_numbers.h
file_xfer.h
http.C,h
pers_file_xfer.C,h
test_http.C
html_ops/
db.php
html_user/
db.inc
test/
1sec_result
account2.xml
*_result
*_wu
init.inc
laptop_prefs.xml
test_*.php
tools/
add.C
10 changes: 9 additions & 1 deletion client/client_state.C
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ int CLIENT_STATE::write_state_file() {
FILE* f = fopen(STATE_FILE_TEMP, "w");
int retval;

if (log_flags.state_debug) {
printf("Writing state file\n");
}
if (!f) {
fprintf(stderr, "can't open temp state file: %s\n", STATE_FILE_TEMP);
return ERR_FOPEN;
Expand Down Expand Up @@ -264,6 +267,9 @@ int CLIENT_STATE::write_state_file() {
fprintf(f, "</client_state>\n");
fclose(f);
retval = rename(STATE_FILE_TEMP, STATE_FILE_NAME);
if (log_flags.state_debug) {
printf("Done writing state file\n");
}
if (retval) return ERR_RENAME;
return 0;
}
Expand Down Expand Up @@ -497,7 +503,9 @@ bool CLIENT_STATE::garbage_collect() {
while (wu_iter != workunits.end()) {
wup = *wu_iter;
if (wup->ref_cnt == 0) {
if (log_flags.state_debug) printf("deleting workunit %s\n", wup->name);
if (log_flags.state_debug) {
printf("deleting workunit %s\n", wup->name);
}
delete wup;
wu_iter = workunits.erase(wu_iter);
action = true;
Expand Down
Loading

0 comments on commit 7d98c6f

Please sign in to comment.