2003-02-10 18:45:27 +00:00
|
|
|
// The contents of this file are subject to the Mozilla 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
|
|
|
|
// http://www.mozilla.org/MPL/
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// 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>
|
|
|
|
|
|
|
|
#include "hostinfo.h"
|
|
|
|
|
2003-02-11 00:52:44 +00:00
|
|
|
#define MAX_BLOB_LEN 4096
|
2002-12-06 07:33:45 +00:00
|
|
|
#define DEFAULT_MAX_PROCESSING 1e10
|
|
|
|
#define DEFAULT_MAX_DISK 1e10
|
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:
|
2002-06-21 06:52:47 +00:00
|
|
|
// the following items come from prefs.xml
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
vector<STRING256> scheduler_urls; // where to find scheduling servers
|
|
|
|
char project_name[256]; // descriptive. not unique
|
|
|
|
char user_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
|
|
|
|
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
|
2003-02-11 00:52:44 +00:00
|
|
|
char code_sign_key[MAX_BLOB_LEN];
|
2002-07-15 05:34:32 +00:00
|
|
|
int nrpc_failures; // # of consecutive times we've failed to
|
|
|
|
// contact all scheduling servers
|
|
|
|
int min_rpc_time; // earliest time to contact any server
|
|
|
|
// of this project (or zero)
|
2002-11-18 23:15:32 +00:00
|
|
|
int master_fetch_failures;
|
2002-07-15 05:34:32 +00:00
|
|
|
// 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
|
|
|
|
bool master_url_fetch_pending;
|
|
|
|
// need to fetch and parse the master URL
|
2003-02-13 23:02:45 +00:00
|
|
|
bool sched_rpc_pending;
|
|
|
|
// need to contact the scheduling server for user/project info
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
PROJECT();
|
|
|
|
~PROJECT();
|
|
|
|
void copy_state_fields(PROJECT&);
|
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*);
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct APP {
|
|
|
|
char name[256];
|
|
|
|
PROJECT* project;
|
|
|
|
|
|
|
|
int parse(FILE*);
|
|
|
|
int write(FILE*);
|
|
|
|
};
|
|
|
|
|
2002-08-13 22:36:54 +00:00
|
|
|
// If the status is neither of these two, it will be
|
|
|
|
// an error code defined in err_numbers.h
|
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];
|
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;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
2002-12-06 07:33:45 +00:00
|
|
|
double seconds_to_complete;
|
|
|
|
// estimated CPU time, based on server-supplied resource estimates
|
|
|
|
// together with host info.
|
2002-12-05 19:13:06 +00:00
|
|
|
double max_processing; // abort if use this many cobblestones
|
|
|
|
double max_disk; // abort if use this much 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
|
|
|
};
|
|
|
|
|
2002-08-22 20:19:18 +00:00
|
|
|
#define RESULT_NEW 0
|
|
|
|
// New result, files may still need to be downloaded
|
|
|
|
#define RESULT_FILES_DOWNLOADED 1
|
|
|
|
// Files are downloaded, result can be computed
|
|
|
|
#define RESULT_COMPUTE_DONE 2
|
2002-12-05 19:13:06 +00:00
|
|
|
// Computation is done, if no error then files need to be uploaded
|
2003-02-06 01:02:56 +00:00
|
|
|
#define RESULT_FILES_UPLOADED 3
|
2002-08-22 20:19:18 +00:00
|
|
|
// Files are uploaded, notify scheduling server
|
2003-01-07 01:02:08 +00:00
|
|
|
|
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
|
|
|
|
// was an error and we are ready to report this to
|
|
|
|
// the server
|
|
|
|
bool server_ack; // received the ack for the report of
|
|
|
|
// 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-02-11 00:52:44 +00:00
|
|
|
char stderr_out[MAX_BLOB_LEN];
|
2003-02-06 01:02:56 +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
|