69 | | // make a unique name (for the job and its input file) |
70 | | // |
71 | | sprintf(name, "%s_%d_%d", app_name, start_time, seqno++); |
| 73 | if(!strcmp(input_dir, "none")) { |
| 74 | // make a unique name (for the job and its input file) |
| 75 | // |
| 76 | sprintf(name, "%s_%d_%d", app_name, start_time, seqno++); |
73 | | // Create the input file. |
74 | | // Put it at the right place in the download dir hierarchy |
75 | | // |
76 | | retval = config.download_path(name, path); |
77 | | if (retval) return retval; |
78 | | FILE* f = fopen(path, "w"); |
79 | | if (!f) return ERR_FOPEN; |
80 | | fprintf(f, "This is the input file for job %s", name); |
81 | | fclose(f); |
| 78 | // Create the input file. |
| 79 | // Put it at the right place in the download dir hierarchy |
| 80 | // |
| 81 | retval = config.download_path(name, path); |
| 82 | if (retval) return retval; |
| 83 | FILE* f = fopen(path, "w"); |
| 84 | if (!f) return ERR_FOPEN; |
| 85 | fprintf(f, "This is the input file for job %s", name); |
| 86 | fclose(f); |
| 87 | } else { |
| 88 | // make a unique name (for the job and its input file) |
| 89 | // |
| 90 | sprintf(name, "%s_%s_%d_%d", app_name, filename, start_time, seqno++); |
| 91 | log_messages.printf(MSG_DEBUG, |
| 92 | "found input file %s and creating job %s\n", filename, name |
| 93 | ); |
| 94 | retval = config.download_path(name, dst_path); |
| 95 | if (retval) return retval; |
| 96 | sprintf(src_path, "%s/%s", input_dir, filename); |
| 97 | log_messages.printf(MSG_DEBUG, |
| 98 | "move file from %s to %s\n", src_path, dst_path |
| 99 | ); |
| 100 | retval = rename(src_path, dst_path); |
| 101 | if (retval) { |
| 102 | log_messages.printf(MSG_CRITICAL, |
| 103 | "rename: %d, errno is %d\n", retval, errno |
| 104 | ); |
| 105 | return retval; |
| 106 | } |
| 107 | } |
85 | | wu.clear(); |
86 | | wu.appid = app.id; |
87 | | strcpy(wu.name, name); |
88 | | wu.rsc_fpops_est = 1e12; |
89 | | wu.rsc_fpops_bound = 1e14; |
90 | | wu.rsc_memory_bound = 1e8; |
91 | | wu.rsc_disk_bound = 1e8; |
92 | | wu.delay_bound = 86400; |
93 | | wu.min_quorum = REPLICATION_FACTOR; |
94 | | wu.target_nresults = REPLICATION_FACTOR; |
95 | | wu.max_error_results = REPLICATION_FACTOR*4; |
96 | | wu.max_total_results = REPLICATION_FACTOR*8; |
97 | | wu.max_success_results = REPLICATION_FACTOR*4; |
| 111 | job.clear(); |
| 112 | job.appid = app.id; |
| 113 | strcpy(job.name, name); |
| 114 | job.rsc_fpops_est = 1e12; |
| 115 | job.rsc_fpops_bound = 1e14; |
| 116 | job.rsc_memory_bound = 1e8; |
| 117 | job.rsc_disk_bound = 1e8; |
| 118 | job.delay_bound = 86400; |
| 119 | job.min_quorum = REPLICATION_FACTOR; |
| 120 | job.target_nresults = REPLICATION_FACTOR; |
| 121 | job.max_error_results = REPLICATION_FACTOR*4; |
| 122 | job.max_total_results = REPLICATION_FACTOR*8; |
| 123 | job.max_success_results = REPLICATION_FACTOR*4; |
130 | | int njobs = (CUSHION-n)/REPLICATION_FACTOR; |
131 | | log_messages.printf(MSG_DEBUG, |
132 | | "Making %d jobs\n", njobs |
133 | | ); |
134 | | for (int i=0; i<njobs; i++) { |
135 | | retval = make_job(); |
136 | | if (retval) { |
137 | | log_messages.printf(MSG_CRITICAL, |
138 | | "can't make job: %s\n", boincerror(retval) |
| 157 | if(!strcmp(input_dir, "none")) { |
| 158 | int njobs = (CUSHION-n)/REPLICATION_FACTOR; |
| 159 | log_messages.printf(MSG_DEBUG, |
| 160 | "Making %d jobs\n", njobs |
| 161 | ); |
| 162 | for (int i=0; i<njobs; i++) { |
| 163 | retval = make_job(); |
| 164 | if (retval) { |
| 165 | log_messages.printf(MSG_CRITICAL, |
| 166 | "can't make job: %s\n", boincerror(retval) |
| 167 | ); |
| 168 | exit(retval); |
| 169 | } |
| 170 | } |
| 171 | } else { |
| 172 | DirScanner dirscan(input_dir); |
| 173 | // check if there are files in input_dir |
| 174 | if (dirscan.scan(file)) { |
| 175 | // files found, now create work for them |
| 176 | int njobs = (CUSHION-n)/REPLICATION_FACTOR; |
| 177 | log_messages.printf(MSG_DEBUG, |
| 178 | "Making %d jobs from files in %s\n", njobs, input_dir |
140 | | exit(retval); |
| 180 | for (int i=0; i<njobs; i++) { |
| 181 | retval = make_job(file.c_str()); |
| 182 | if (retval) { |
| 183 | log_messages.printf(MSG_CRITICAL, |
| 184 | "can't make job: %s\n", boincerror(retval) |
| 185 | ); |
| 186 | exit(retval); |
| 187 | } |
| 188 | if (!dirscan.scan(file)) { |
| 189 | log_messages.printf(MSG_DEBUG, |
| 190 | "no more input files in: %s\n", input_dir |
| 191 | ); |
| 192 | break; // no more files but CUSHION not yet reached |
| 193 | } |
| 194 | } |
| 195 | } else { |
| 196 | // no more files found, wait some time |
| 197 | log_messages.printf(MSG_DEBUG, |
| 198 | "no more input files in: %s\n", input_dir |
| 199 | ); |
| 200 | daemon_sleep(60); //increase this time if you can't supply a steady stream of input files |