2003-07-01 20:37:09 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
2002-04-30 22:22:54 +00:00
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
2003-07-01 20:37:09 +00:00
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2003-07-03 00:48:43 +00:00
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
2003-07-03 00:48:43 +00:00
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
2003-07-03 00:48:43 +00:00
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
|
|
|
// If you change anything, make sure you also change:
|
|
|
|
// types.C (to write and parse it)
|
|
|
|
// client_state.C (to cross-link objects)
|
|
|
|
//
|
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
#ifndef _CLIENT_TYPES_
|
|
|
|
#define _CLIENT_TYPES_
|
2002-08-22 20:23:24 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2002-08-22 20:41:56 +00:00
|
|
|
#include "windows_cpp.h"
|
2002-08-22 20:23:24 +00:00
|
|
|
#endif
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2003-07-03 05:01:29 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <time.h>
|
|
|
|
#else
|
|
|
|
#include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "hostinfo.h"
|
2003-06-11 18:38:08 +00:00
|
|
|
#include "result_state.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2003-02-11 00:52:44 +00:00
|
|
|
#define MAX_BLOB_LEN 4096
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-08-07 22:52:10 +00:00
|
|
|
class PERS_FILE_XFER;
|
2002-07-22 23:07:14 +00:00
|
|
|
struct RESULT;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-06-10 06:14:18 +00:00
|
|
|
struct STRING256 {
|
|
|
|
char text[256];
|
|
|
|
};
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
class PROJECT {
|
|
|
|
public:
|
2003-02-28 23:14:18 +00:00
|
|
|
// the following items come from the account file
|
2002-06-21 06:52:47 +00:00
|
|
|
// They are a function only of the user and the project
|
|
|
|
//
|
2002-07-15 23:37:55 +00:00
|
|
|
char master_url[256]; // url of site that contains scheduler tags
|
|
|
|
// for this project
|
2002-04-30 22:22:54 +00:00
|
|
|
char authenticator[256]; // user's authenticator on this project
|
2003-02-11 00:52:44 +00:00
|
|
|
char project_specific_prefs[MAX_BLOB_LEN]; // without enclosing tags
|
2002-06-21 06:52:47 +00:00
|
|
|
double resource_share; // project's resource share
|
|
|
|
// relative to other projects. Arbitrary scale.
|
|
|
|
|
|
|
|
// the following items come from client_state.xml
|
|
|
|
// They may depend on the host as well as user and project
|
2003-05-13 18:55:07 +00:00
|
|
|
// NOTE: if you add anything, add it to copy_state_fields() also!!!
|
2002-06-21 06:52:47 +00:00
|
|
|
//
|
|
|
|
vector<STRING256> scheduler_urls; // where to find scheduling servers
|
|
|
|
char project_name[256]; // descriptive. not unique
|
|
|
|
char user_name[256];
|
2003-02-24 21:25:16 +00:00
|
|
|
char team_name[256];
|
2002-11-19 22:57:05 +00:00
|
|
|
double user_total_credit; // as reported by server
|
|
|
|
double user_expavg_credit; // as reported by server
|
2002-10-22 21:44:16 +00:00
|
|
|
unsigned int user_create_time; // as reported by server
|
2002-04-30 22:22:54 +00:00
|
|
|
int rpc_seqno;
|
|
|
|
int hostid;
|
2002-10-22 21:44:16 +00:00
|
|
|
double host_total_credit; // as reported by server
|
|
|
|
double host_expavg_credit; // as reported by server
|
2003-07-03 00:48:43 +00:00
|
|
|
unsigned int host_create_time; // as reported by server
|
2002-07-15 05:34:32 +00:00
|
|
|
double exp_avg_cpu; // exponentially weighted CPU time
|
2002-04-30 22:22:54 +00:00
|
|
|
int exp_avg_mod_time; // last time average was changed
|
2002-07-15 05:34:32 +00:00
|
|
|
int nrpc_failures; // # of consecutive times we've failed to
|
|
|
|
// contact all scheduling servers
|
2003-02-28 23:14:18 +00:00
|
|
|
int master_fetch_failures;
|
2003-07-03 00:48:43 +00:00
|
|
|
time_t min_rpc_time; // earliest time to contact any server
|
|
|
|
// of this project (or zero)
|
|
|
|
time_t min_report_min_rpc_time; // when to next report on min_rpc_time
|
|
|
|
// (or zero)
|
2002-07-15 05:34:32 +00:00
|
|
|
bool master_url_fetch_pending;
|
|
|
|
// need to fetch and parse the master URL
|
2003-05-13 18:55:07 +00:00
|
|
|
bool sched_rpc_pending; // contact scheduling server for preferences
|
|
|
|
bool tentative; // master URL and account ID not confirmed
|
2003-02-28 23:14:18 +00:00
|
|
|
char code_sign_key[MAX_BLOB_LEN];
|
|
|
|
|
|
|
|
// the following items are transient; not saved in state file
|
|
|
|
double resource_debt; // How much CPU time we owe this project
|
|
|
|
// (arbitrary scale)
|
|
|
|
int debt_order; // 0 == largest debt
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
PROJECT();
|
|
|
|
~PROJECT();
|
2003-06-23 22:05:14 +00:00
|
|
|
void init();
|
2002-06-21 06:52:47 +00:00
|
|
|
void copy_state_fields(PROJECT&);
|
2003-05-08 23:28:01 +00:00
|
|
|
char *get_project_name();
|
2003-05-13 18:55:07 +00:00
|
|
|
int write_account_file();
|
2002-09-26 05:57:10 +00:00
|
|
|
int parse_account(FILE*);
|
2002-06-21 06:52:47 +00:00
|
|
|
int parse_state(FILE*);
|
|
|
|
int write_state(FILE*);
|
2003-07-03 00:48:43 +00:00
|
|
|
|
|
|
|
// set min_rpc_time and have_reported_min_rpc_time
|
|
|
|
void set_min_rpc_time(time_t future_time);
|
|
|
|
// returns true if min_rpc_time > now; may print a message
|
|
|
|
bool waiting_until_min_rpc_time(time_t now);
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct APP {
|
|
|
|
char name[256];
|
|
|
|
PROJECT* project;
|
|
|
|
|
|
|
|
int parse(FILE*);
|
|
|
|
int write(FILE*);
|
|
|
|
};
|
|
|
|
|
2003-05-21 23:23:42 +00:00
|
|
|
// If the status is neither of these two,
|
|
|
|
// it will be an error code defined in error_numbers.h,
|
|
|
|
// indicating an unrecoverable error in the upload or download of the file
|
|
|
|
//
|
2002-08-12 21:54:19 +00:00
|
|
|
#define FILE_NOT_PRESENT 0
|
|
|
|
#define FILE_PRESENT 1
|
|
|
|
|
2002-06-10 06:14:18 +00:00
|
|
|
class FILE_INFO {
|
|
|
|
public:
|
2002-04-30 22:22:54 +00:00
|
|
|
char name[256];
|
|
|
|
char md5_cksum[33];
|
2002-07-05 05:33:40 +00:00
|
|
|
double max_nbytes;
|
2002-04-30 22:22:54 +00:00
|
|
|
double nbytes;
|
2002-08-12 21:54:19 +00:00
|
|
|
double upload_offset;
|
2002-04-30 22:22:54 +00:00
|
|
|
bool generated_locally; // file is produced by app
|
2002-08-12 21:54:19 +00:00
|
|
|
int status;
|
2002-07-07 20:39:24 +00:00
|
|
|
bool executable; // change file protections to make executable
|
2002-04-30 22:22:54 +00:00
|
|
|
bool uploaded; // file has been uploaded
|
|
|
|
bool upload_when_present;
|
|
|
|
bool sticky; // don't delete unless instructed to do so
|
2002-07-07 20:39:24 +00:00
|
|
|
bool signature_required; // true iff associated with app version
|
2002-08-07 22:52:10 +00:00
|
|
|
PERS_FILE_XFER* pers_file_xfer; // nonzero if in the process of being up/downloaded
|
2002-07-05 05:33:40 +00:00
|
|
|
RESULT* result; // for upload files (to authenticate)
|
2002-04-30 22:22:54 +00:00
|
|
|
PROJECT* project;
|
|
|
|
int ref_cnt;
|
2002-06-10 06:14:18 +00:00
|
|
|
vector<STRING256> urls;
|
2002-08-07 22:52:10 +00:00
|
|
|
int start_url;
|
|
|
|
int current_url;
|
2003-02-11 00:52:44 +00:00
|
|
|
char signed_xml[MAX_BLOB_LEN];
|
|
|
|
char xml_signature[MAX_BLOB_LEN];
|
|
|
|
char file_signature[MAX_BLOB_LEN];
|
2003-06-17 22:00:55 +00:00
|
|
|
bool approval_required; // true if the file requires user approval
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-06-10 06:14:18 +00:00
|
|
|
FILE_INFO();
|
|
|
|
~FILE_INFO();
|
2002-08-21 19:12:42 +00:00
|
|
|
int set_permissions();
|
2002-07-05 05:33:40 +00:00
|
|
|
int parse(FILE*, bool from_server);
|
2002-04-30 22:22:54 +00:00
|
|
|
int write(FILE*, bool to_server);
|
|
|
|
int delete_file(); // attempt to delete the underlying file
|
2002-08-07 22:52:10 +00:00
|
|
|
char* get_url();
|
2002-12-05 21:35:51 +00:00
|
|
|
bool had_failure(int& failnum);
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
2002-05-17 22:33:57 +00:00
|
|
|
// Describes a connection between a file and a workunit, result, or application.
|
|
|
|
// In the first two cases,
|
|
|
|
// the app will either use open() or fopen() to access the file
|
2002-04-30 22:22:54 +00:00
|
|
|
// (in which case "open_name" is the name it will use)
|
|
|
|
// or the app will be connected by the given fd (in which case fd is nonzero)
|
|
|
|
//
|
2002-05-17 22:33:57 +00:00
|
|
|
struct FILE_REF {
|
2002-04-30 22:22:54 +00:00
|
|
|
char file_name[256];
|
|
|
|
char open_name[256];
|
|
|
|
int fd;
|
2002-05-17 22:33:57 +00:00
|
|
|
bool main_program;
|
2002-04-30 22:22:54 +00:00
|
|
|
FILE_INFO* file_info;
|
2003-07-01 18:27:08 +00:00
|
|
|
bool copy_file; // if true, core client will copy the file instead of linking
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-06-10 06:14:18 +00:00
|
|
|
int parse(FILE*);
|
|
|
|
int write(FILE*);
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
2002-05-17 22:33:57 +00:00
|
|
|
struct APP_VERSION {
|
|
|
|
char app_name[256];
|
|
|
|
int version_num;
|
|
|
|
APP* app;
|
|
|
|
PROJECT* project;
|
|
|
|
vector<FILE_REF> app_files;
|
2003-03-02 19:24:09 +00:00
|
|
|
int ref_cnt;
|
2002-05-17 22:33:57 +00:00
|
|
|
|
|
|
|
int parse(FILE*);
|
|
|
|
int write(FILE*);
|
|
|
|
};
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
struct WORKUNIT {
|
|
|
|
char name[256];
|
|
|
|
char app_name[256];
|
|
|
|
int version_num;
|
|
|
|
// This isn't sent from the server.
|
2002-07-29 00:39:45 +00:00
|
|
|
// Instead, the client picks the latest app version
|
2002-04-30 22:22:54 +00:00
|
|
|
char command_line[256];
|
|
|
|
char env_vars[256]; // environment vars in URL format
|
2002-05-17 22:33:57 +00:00
|
|
|
vector<FILE_REF> input_files;
|
2002-04-30 22:22:54 +00:00
|
|
|
PROJECT* project;
|
|
|
|
APP* app;
|
|
|
|
APP_VERSION* avp;
|
|
|
|
int ref_cnt;
|
2003-05-21 23:23:42 +00:00
|
|
|
double rsc_fpops;
|
|
|
|
double rsc_iops;
|
|
|
|
double rsc_memory;
|
|
|
|
double rsc_disk;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
int parse(FILE*);
|
|
|
|
int write(FILE*);
|
2002-12-05 21:35:51 +00:00
|
|
|
bool had_failure(int& failnum);
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RESULT {
|
|
|
|
char name[256];
|
|
|
|
char wu_name[256];
|
2002-07-15 05:34:32 +00:00
|
|
|
int report_deadline;
|
2002-05-17 22:33:57 +00:00
|
|
|
vector<FILE_REF> output_files;
|
2002-04-30 22:22:54 +00:00
|
|
|
bool is_active; // an app is currently running for this
|
2003-02-06 01:02:56 +00:00
|
|
|
bool ready_to_ack; // all the files have been uploaded or there
|
2003-07-03 00:48:43 +00:00
|
|
|
// was an error and we are ready to report this to
|
2003-02-06 01:02:56 +00:00
|
|
|
// the server
|
2003-07-03 00:48:43 +00:00
|
|
|
bool server_ack; // received the ack for the report of
|
2003-02-06 01:02:56 +00:00
|
|
|
// the status of the result from server
|
2002-08-05 00:29:34 +00:00
|
|
|
double final_cpu_time;
|
2003-02-06 01:02:56 +00:00
|
|
|
int state; // state of this result, see above
|
2002-08-12 21:54:19 +00:00
|
|
|
int exit_status; // return value from the application
|
2003-02-06 01:02:56 +00:00
|
|
|
int signal; // the signal caught by the active_task,
|
2003-01-07 01:02:08 +00:00
|
|
|
// defined only if active_task_state is PROCESS_SIGNALED
|
2002-12-05 21:35:51 +00:00
|
|
|
int active_task_state; // the state of the active task corresponding to this result
|
2003-06-27 23:13:15 +00:00
|
|
|
string stderr_out;
|
2003-07-03 00:48:43 +00:00
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
APP* app;
|
|
|
|
WORKUNIT* wup;
|
|
|
|
PROJECT* project;
|
|
|
|
|
2002-07-05 05:33:40 +00:00
|
|
|
void clear();
|
|
|
|
int parse_server(FILE*);
|
|
|
|
int parse_state(FILE*);
|
|
|
|
int parse_ack(FILE*);
|
2002-04-30 22:22:54 +00:00
|
|
|
int write(FILE*, bool to_server);
|
|
|
|
bool is_upload_done(); // files uploaded?
|
|
|
|
};
|
|
|
|
|
2002-08-07 22:52:10 +00:00
|
|
|
int verify_downloaded_file(char* pathname, FILE_INFO& file_info);
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
#endif
|