00001 // This file is part of BOINC. 00002 // http://boinc.berkeley.edu 00003 // Copyright (C) 2008 University of California 00004 // 00005 // BOINC is free software; you can redistribute it and/or modify it 00006 // under the terms of the GNU Lesser General Public License 00007 // as published by the Free Software Foundation, 00008 // either version 3 of the License, or (at your option) any later version. 00009 // 00010 // BOINC is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00013 // See the GNU Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with BOINC. If not, see <http://www.gnu.org/licenses/>. 00017 00018 #ifndef _SCHEDULER_OP_ 00019 #define _SCHEDULER_OP_ 00020 00021 #include <vector> 00022 00023 #include "client_types.h" 00024 #include "auto_update.h" 00025 #include "http_curl.h" 00026 #include "prefs.h" 00027 00028 #define SCHEDULER_OP_STATE_IDLE 0 00029 // invariant: in this state, our HTTP_OP is not in the HTTP_OP_SET 00030 #define SCHEDULER_OP_STATE_GET_MASTER 1 00031 #define SCHEDULER_OP_STATE_RPC 2 00032 00033 // defaults related to scheduler RPC policy 00034 // See client_state.h for definitions 00035 00036 #define MASTER_FETCH_PERIOD 10 00037 // fetch and parse master URL if nrpc_failures is a multiple of this 00038 #define RETRY_CAP 10 00039 // cap on nrpc_failures 00040 #define MASTER_FETCH_RETRY_CAP 3 00041 // after this many master-fetch failures, 00042 // move into a state in which we retry master fetch 00043 // at the frequency below 00044 #define MASTER_FETCH_INTERVAL (86400) // 1 day 00045 // See above 00046 00047 // constants used to bound RPC backoff 00048 #define SCHED_RETRY_DELAY_MIN 60 // 1 minute 00049 #define SCHED_RETRY_DELAY_MAX (60*60*4) // 4 hours 00050 00051 00056 00057 class SCHEDULER_OP { 00058 private: 00059 int scheduler_op_retval; 00060 HTTP_OP http_op; 00061 HTTP_OP_SET* http_ops; 00062 char scheduler_url[256]; 00064 int url_index; 00065 public: 00067 PROJECT* cur_proj; 00068 int state; 00069 int reason; 00071 double url_random; 00072 00073 public: 00074 SCHEDULER_OP(HTTP_OP_SET*); 00075 bool poll(); 00076 int init_get_work(); 00077 int init_op_project(PROJECT*, int); 00078 int init_master_fetch(PROJECT*); 00079 bool check_master_fetch_start(); 00080 void backoff(PROJECT* p, const char *error_msg); 00082 void abort(PROJECT*); 00083 private: 00084 bool update_urls(PROJECT*, std::vector<std::string> &urls); 00085 int start_op(PROJECT*); 00086 int start_rpc(PROJECT*); 00087 int parse_master_file(PROJECT*, std::vector<std::string>&); 00088 }; 00089 00090 struct USER_MESSAGE { 00091 std::string message; 00092 std::string priority; 00093 USER_MESSAGE(char*, char*); 00094 }; 00095 00096 struct SCHEDULER_REPLY { 00097 int hostid; 00098 double request_delay; 00099 double next_rpc_delay; 00100 std::vector<USER_MESSAGE> messages; 00103 char* global_prefs_xml; 00106 char* project_prefs_xml; 00107 char master_url[256]; 00108 char host_venue[256]; 00109 unsigned int user_create_time; 00110 std::vector<APP> apps; 00111 std::vector<FILE_INFO> file_infos; 00112 std::vector<std::string> file_deletes; 00113 std::vector<APP_VERSION> app_versions; 00114 std::vector<WORKUNIT> workunits; 00115 std::vector<RESULT> results; 00116 std::vector<RESULT> result_acks; 00117 std::vector<RESULT> result_abort; 00118 std::vector<RESULT> result_abort_if_not_started; 00119 char* code_sign_key; 00120 char* code_sign_key_signature; 00121 bool message_ack; 00122 bool project_is_down; 00123 bool send_file_list; 00124 int send_time_stats_log; 00125 int send_job_log; 00126 int scheduler_version; 00127 AUTO_UPDATE auto_update; 00128 00129 SCHEDULER_REPLY(); 00130 ~SCHEDULER_REPLY(); 00131 int parse(FILE*, PROJECT*); 00132 }; 00133 00134 #endif
1.5.6