Changeset 33365
- Timestamp:
- Feb 24, 2012, 10:04:28 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src/photdbc
- Files:
-
- 1 added
- 4 edited
-
Makefile (modified) (1 diff)
-
include/dvodist.h (modified) (2 diffs)
-
src/CopyToHostLocation.c (modified) (4 diffs)
-
src/HostTableLoad.c (modified) (3 diffs)
-
src/PclientCommands.c (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/photdbc/Makefile
r33240 r33365 42 42 $(SRC)/AssignSkyToHost.$(ARCH).o \ 43 43 $(SRC)/CopyToHostLocation.$(ARCH).o \ 44 $(SRC)/CopyFromHostLocation.$(ARCH).o 44 $(SRC)/CopyFromHostLocation.$(ARCH).o \ 45 $(SRC)/PclientCommands.$(ARCH).o 45 46 46 47 OLD = \ -
branches/eam_branches/ipp-20111122/Ohana/src/photdbc/include/dvodist.h
r33257 r33365 4 4 # include <md5.h> 5 5 # include <unistd.h> // needed? 6 7 # define PCLIENT_PROMPT "pclient:" 6 8 7 9 // used by the md5 stuff … … 37 39 38 40 int get_md5_with_copy (char *input, char *output, md5_byte_t *digest); 41 42 int CheckBusyJob (HostInfo *host, IOBuffer *stdout_buf, IOBuffer *stderr_buf); 43 int GetJobOutput (char *command, HostInfo *host, IOBuffer *output, int size); 44 int PclientResponse (HostInfo *host, char *response, IOBuffer *buffer); 45 int PclientCommand (HostInfo *host, char *command, IOBuffer *buffer); -
branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/CopyToHostLocation.c
r33361 r33365 4 4 # define DELETE_ORIGINAL 0 5 5 // make this a user option 6 7 int get_md5_from_remote (HostInfo *host, char *filename, md5_byte_t *digest); 8 int get_md5_from_pclient (HostInfo *host, char *filename, md5_byte_t *digest); 9 int hexchar_to_int (char input); 6 10 7 11 // XXX collapse this and CopyFromHostLocation (only difference is name of src/tgt and bits set on success) … … 95 99 96 100 // need to re-open and re-read tgtname to check md5sum 97 // XXX this would be safer and faster if we used the remote shell to perform the md5sum locally.98 if (!get_md5_ with_copy (tgtname, NULL, tgtDigest)) {101 char *absname = abspath (tgtname, 1024); 102 if (!get_md5_from_pclient (host, absname, tgtDigest)) { 99 103 fprintf (stderr, "error reading %s or getting md5\n", tgtname); 100 104 success = FALSE; … … 135 139 sprintf (tgtname, "%s/%s.%s", host->pathname, skylist->regions[i]->name, extname[j]); 136 140 sprintf (srcname, "%s/%s.%s", catdir, skylist->regions[i]->name, extname[j]); 137 138 // do not rename or unlink original if it does not exist..139 status = stat (srcname, &filestat);140 if (status && (errno == ENOENT)) continue;141 141 142 // do not rename or unlink original if it does not exist.. 143 status = stat (srcname, &filestat); 144 if (status && (errno == ENOENT)) continue; 145 142 146 if (!DEBUG && DELETE_ORIGINAL) { 143 147 unlink (srcname); … … 190 194 * read the SPLIT headers to see if MEASURE, MISSING, SECFILT fields exist? 191 195 */ 196 197 // XXX this would be better controlled if we used a remote pclient. then we could 198 // check things like the exit status and 199 int get_md5_from_remote (HostInfo *host, char *filename, md5_byte_t *digest) { 200 201 IOBuffer buffer; 202 203 char line[1024]; 204 int Nline = snprintf (line, 1024, "md5sum %s\n", filename); 205 assert (Nline < 1024); 206 207 write (host->stdio[0], line, Nline); 208 209 InitIOBuffer (&buffer, 100); 210 int status = EmptyIOBuffer (&buffer, 10000, host->stdio[1]); 211 fprintf (stderr, "md5sum status: %d\n", status); 212 213 fprintf (stderr, "buffer: %s\n", buffer.buffer); 214 215 char result[1024], fileout[1024]; 216 int Nscan = sscanf (buffer.buffer, "%s %s", result, fileout); 217 assert (Nscan == 2); 218 assert (strlen(result) == NDIGEST); 219 220 memcpy (digest, result, NDIGEST); 221 return TRUE; 222 } 223 224 // pclient version of remote client 225 int get_md5_from_pclient (HostInfo *host, char *filename, md5_byte_t *digest) { 226 227 IOBuffer buffer, stdout_buf, stderr_buf; 228 229 char line[1024]; 230 int Nline = snprintf (line, 1024, "job md5sum %s\n", filename); 231 assert (Nline < 1024); 232 233 // fprintf (stderr, "command: %s\n", line); 234 235 // start the md5sum command 236 InitIOBuffer (&buffer, 100); 237 PclientCommand (host, line, &buffer); 238 PclientResponse (host, PCLIENT_PROMPT, &buffer); 239 // XXX for the moment, abort if anything goes wrong 240 241 // wait for result 242 while (!CheckBusyJob (host, &stdout_buf, &stderr_buf)) { 243 usleep (10000); 244 } 245 if (stderr_buf.Nbuffer) { 246 fprintf (stderr, "error in md5sum: %s\n", stderr_buf.buffer); 247 exit (1); 248 } 249 250 // fprintf (stderr, "result from md5sum: %s\n", stdout_buf.buffer); 251 252 char result[1024], fileout[1024]; 253 int Nscan = sscanf (stdout_buf.buffer, "%s %s", result, fileout); 254 assert (Nscan == 2); 255 assert (strlen(result) == 2*NDIGEST); 256 257 // result is the set of 0-f nibbles, convert to the digest 258 int i; 259 for (i = 0; i < NDIGEST; i++) { 260 int value1 = hexchar_to_int (result[2*i+0]); 261 int value2 = hexchar_to_int (result[2*i+1]); 262 digest[i] = (value1 << 4) + value2; 263 // fprintf (stderr, "%02x %c %c\n", digest[i], result[2*i], result[2*i+1]); 264 } 265 266 // need to reset pclient for next command... 267 PclientCommand (host, "reset", &buffer); 268 PclientResponse (host, PCLIENT_PROMPT, &buffer); 269 270 return TRUE; 271 } 272 273 int hexchar_to_int (char input) { 274 275 switch (input) { 276 case '0': 277 case '1': 278 case '2': 279 case '3': 280 case '4': 281 case '5': 282 case '6': 283 case '7': 284 case '8': 285 case '9': 286 return input - '0'; 287 case 'a': 288 case 'b': 289 case 'c': 290 case 'd': 291 case 'e': 292 case 'f': 293 return input - 'a' + 10; 294 case 'A': 295 case 'B': 296 case 'C': 297 case 'D': 298 case 'E': 299 case 'F': 300 return input - 'A' + 10; 301 default: 302 abort(); 303 } 304 } -
branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/HostTableLoad.c
r33240 r33365 5 5 6 6 int i; 7 int stdio[3];8 7 char command[64]; 9 8 char shell[64]; 10 9 11 10 strcpy (command, "ssh"); 12 strcpy (shell, " csh");11 strcpy (shell, "pclient"); 13 12 14 13 for (i = 0; i < table->Nhosts; i++) { … … 18 17 19 18 int errorInfo; 20 int pid = rconnect (command, table->hosts[i].hostname, shell, stdio, &errorInfo, TRUE);19 int pid = rconnect (command, table->hosts[i].hostname, shell, table->hosts[i].stdio, &errorInfo, TRUE); 21 20 if (!pid) { 22 21 /** failure to start: extend retry period **/ … … 24 23 exit (1); 25 24 } 26 27 // XXX check anything else? 28 29 // close the connection 30 close(stdio[0]); 31 close(stdio[1]); 32 close(stdio[2]); 25 table->hosts[i].pid = pid; 26 // keep the connection open to use for md5sum check 33 27 34 28 int status = check_dir_access (table->hosts[i].pathname, DEBUG);
Note:
See TracChangeset
for help on using the changeset viewer.
