IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33365


Ignore:
Timestamp:
Feb 24, 2012, 10:04:28 AM (14 years ago)
Author:
eugene
Message:

use a remote md5sum call via pclient to check on successful transfer (do not trust NFS...)

Location:
branches/eam_branches/ipp-20111122/Ohana/src/photdbc
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/Makefile

    r33240 r33365  
    4242$(SRC)/AssignSkyToHost.$(ARCH).o        \
    4343$(SRC)/CopyToHostLocation.$(ARCH).o     \
    44 $(SRC)/CopyFromHostLocation.$(ARCH).o
     44$(SRC)/CopyFromHostLocation.$(ARCH).o   \
     45$(SRC)/PclientCommands.$(ARCH).o
    4546
    4647OLD = \
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/include/dvodist.h

    r33257 r33365  
    44# include <md5.h>
    55# include <unistd.h> // needed?
     6
     7# define PCLIENT_PROMPT "pclient:"
    68
    79// used by the md5 stuff
     
    3739
    3840int           get_md5_with_copy (char *input, char *output, md5_byte_t *digest);
     41
     42int CheckBusyJob (HostInfo *host, IOBuffer *stdout_buf, IOBuffer *stderr_buf);
     43int GetJobOutput (char *command, HostInfo *host, IOBuffer *output, int size);
     44int PclientResponse (HostInfo *host, char *response, IOBuffer *buffer);
     45int PclientCommand (HostInfo *host, char *command, IOBuffer *buffer);
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/CopyToHostLocation.c

    r33361 r33365  
    44# define DELETE_ORIGINAL 0
    55// make this a user option
     6
     7int get_md5_from_remote (HostInfo *host, char *filename, md5_byte_t *digest);
     8int get_md5_from_pclient (HostInfo *host, char *filename, md5_byte_t *digest);
     9int hexchar_to_int (char input);
    610
    711// XXX collapse this and CopyFromHostLocation (only difference is name of src/tgt and bits set on success)
     
    9599       
    96100      // 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)) {
    99103        fprintf (stderr, "error reading %s or getting md5\n", tgtname);
    100104        success = FALSE;
     
    135139        sprintf (tgtname, "%s/%s.%s", host->pathname, skylist->regions[i]->name, extname[j]);
    136140        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
    142146        if (!DEBUG && DELETE_ORIGINAL) {
    143147          unlink (srcname);
     
    190194 * read the SPLIT headers to see if MEASURE, MISSING, SECFILT fields exist?
    191195 */
     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
     199int 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
     225int 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
     273int 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  
    55
    66  int i;
    7   int stdio[3];
    87  char command[64];
    98  char shell[64];
    109
    1110  strcpy (command, "ssh");
    12   strcpy (shell, "csh");
     11  strcpy (shell, "pclient");
    1312
    1413  for (i = 0; i < table->Nhosts; i++) {
     
    1817
    1918    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);
    2120    if (!pid) {     
    2221      /** failure to start: extend retry period **/
     
    2423      exit (1);
    2524    }
    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
    3327
    3428    int status = check_dir_access (table->hosts[i].pathname, DEBUG);
Note: See TracChangeset for help on using the changeset viewer.