IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34119


Ignore:
Timestamp:
Jul 5, 2012, 9:11:28 AM (14 years ago)
Author:
eugene
Message:

add more options to purge-temp; write the commandFile outside of remote loop

Location:
branches/eam_branches/ipp-20120627/Ohana/src/opihi/dvo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120627/Ohana/src/opihi/dvo/dvo_host_utils.c

    r33963 r34119  
    1515  snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    1616
     17  // write the dvo comment (host independent)
     18  char commandBase[DVO_MAX_PATH];
     19  snprintf (commandBase, DVO_MAX_PATH, "dvo.command.%s.txt", uniquer);
     20  char *commandFile = abspath(commandBase, DVO_MAX_PATH);
     21
     22  FILE *f = fopen (commandFile, "w");
     23  fprintf (f, "%s\n", basecmd);
     24  if (fflush (f)) DIE("flush", "failed to flush");
     25
     26  int fd = fileno (f);
     27  if (fsync (fd)) DIE("fsync", "failed to fsync");
     28
     29  if (fclose (f)) DIE("close", "failed to close");
     30
     31  // force NFS to write the file to disk
     32  int state;
     33  f = fsetlockfile (commandFile, 0.5, LCK_XCLD, &state);
     34  fclearlockfile (commandFile, f, LCK_XCLD, &state);
     35
    1736  int top_status = TRUE;
    1837  int i;
     
    2948    snprintf (table->hosts[i].results, DVO_MAX_PATH, "%s/dvo.results.%s.fits", table->hosts[i].pathname, uniquer);
    3049
    31     char commandBase[DVO_MAX_PATH];
    32     snprintf (commandBase, DVO_MAX_PATH, "dvo.command.%s.txt", uniquer);
    33     char *commandFile = abspath(commandBase, DVO_MAX_PATH);
    34 
    35     FILE *f = fopen (commandFile, "w");
    36     fprintf (f, "%s\n", basecmd);
    37     if (fflush (f)) DIE("flush", "failed to flush");
    38 
    39     int fd = fileno (f);
    40     if (fsync (fd)) DIE("fsync", "failed to fsync");
    41 
    42     if (fclose (f)) DIE("close", "failed to close");
    43 
    44     // force NFS to write the file to disk
    45     int state;
    46     f = fsetlockfile (commandFile, 0.5, LCK_XCLD, &state);
    47     fclearlockfile (commandFile, f, LCK_XCLD, &state);
    48 
    4950    char command[1024];
    5051    snprintf (command, 1024, "dvo_client %s -result %s %s -hostID %d -hostdir %s", commandFile, table->hosts[i].results, options, table->hosts[i].hostID, table->hosts[i].pathname);
    51     free (commandFile);
    5252
    5353    if (VERBOSE) gprint (GP_ERR, "command: %s\n", command);
     
    7575    }
    7676  }
     77  free (commandFile);
    7778  return top_status;
    7879}
  • branches/eam_branches/ipp-20120627/Ohana/src/opihi/dvo/hosts.c

    r34088 r34119  
    22# include <glob.h>
    33# define DVO_MAX_PATH 1024
     4
     5enum {TEMP_NONE, TEMP_DVO_RESULTS, TEMP_DVO_LOG, TEMP_RELPHOT_RESULTS, TEMP_RELPHOT_LOG};
    46
    57// functions to manage the remote hosts
     
    1012    gprint (GP_ERR, "  commands:\n");
    1113    gprint (GP_ERR, "    purge-temp : delete all tempfiles for this shell\n");
     14    gprint (GP_ERR, "               : [-old-pid] [-all-pid] [-v] [-verbose] [-commit] [-type type]\n");
     15    gprint (GP_ERR, "    get-results : determine name of RESULTS file\n");
    1216    return FALSE;
    1317  }
     
    2731      remove_argument (N, &argc, argv);
    2832      ALL_PID = TRUE;
    29       remove_argument (N, &argc, argv);
    3033    }
    3134   
     
    4649    }
    4750   
     51    // we have the following types of temp files:
     52    // dvo.results.*.fits
     53    // dvo.results.*.fits.log
     54    // log.rlpc.* (relphot logs)
     55    // relphot.catalog.subset.dat [no glob needed]
     56    int TEMP_TYPE = TEMP_DVO_RESULTS;
     57    if ((N = get_argument (argc, argv, "-type"))) {
     58      TEMP_TYPE = TEMP_NONE;
     59      remove_argument (N, &argc, argv);
     60      if (!strcasecmp(argv[N], "dvo.results"))     TEMP_TYPE = TEMP_DVO_RESULTS;
     61      if (!strcasecmp(argv[N], "dvo.log"))         TEMP_TYPE = TEMP_DVO_LOG;
     62      if (!strcasecmp(argv[N], "relphot.results")) TEMP_TYPE = TEMP_RELPHOT_RESULTS;
     63      if (!strcasecmp(argv[N], "relphot.log"))     TEMP_TYPE = TEMP_RELPHOT_LOG;
     64      if (TEMP_TYPE == TEMP_NONE) {
     65        gprint (GP_ERR, "USAGE: hosts purge-temp [-type (type)]\n");
     66        gprint (GP_ERR, "  allowed types dvo.results, dvo.log, relphot.results, relphot.log]\n");
     67        return FALSE;
     68      }
     69      remove_argument (N, &argc, argv);
     70    }
     71
    4872    // XXX wrap this up in a function:
    4973    char *CATDIR = GetCATDIR();
     
    6387    }   
    6488   
     89    if (argc != 2) {
     90      gprint (GP_ERR, "USAGE: hosts purge-temp [-all-pid] [-old-pid PID] [-verbose] [-commit]\n");
     91      return FALSE;
     92    }
     93
    6594    int i;
    6695    for (i = 0; i < table->Nhosts; i++) {
     
    6897      char name[DVO_MAX_PATH];
    6998      if (ALL_PID) {
    70         snprintf (name, DVO_MAX_PATH, "%s/dvo.results.*.*.fits", table->hosts[i].pathname);
     99        if (TEMP_TYPE == TEMP_DVO_RESULTS)     snprintf (name, DVO_MAX_PATH, "%s/dvo.results.*.fits", table->hosts[i].pathname);
     100        if (TEMP_TYPE == TEMP_DVO_LOG)         snprintf (name, DVO_MAX_PATH, "%s/dvo.results.*.fits.log", table->hosts[i].pathname);
     101        if (TEMP_TYPE == TEMP_RELPHOT_RESULTS) snprintf (name, DVO_MAX_PATH, "%s/log.rlpc.*", table->hosts[i].pathname);
     102        if (TEMP_TYPE == TEMP_RELPHOT_LOG)     snprintf (name, DVO_MAX_PATH, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname);
    71103      } else {
    72         snprintf (name, DVO_MAX_PATH, "%s/dvo.results.%05d.*.fits", table->hosts[i].pathname, PID);
     104        if (TEMP_TYPE == TEMP_DVO_RESULTS)     snprintf (name, DVO_MAX_PATH, "%s/dvo.results.%05d.*.fits", table->hosts[i].pathname, PID);
     105        if (TEMP_TYPE == TEMP_DVO_LOG)         snprintf (name, DVO_MAX_PATH, "%s/dvo.results.%05d.*.fits.log", table->hosts[i].pathname, PID);
     106        if (TEMP_TYPE == TEMP_RELPHOT_RESULTS) snprintf (name, DVO_MAX_PATH, "%s/log.rlpc.*", table->hosts[i].pathname);
     107        if (TEMP_TYPE == TEMP_RELPHOT_LOG)     snprintf (name, DVO_MAX_PATH, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname);
    73108      }
    74109      if (VERBOSE) gprint (GP_ERR, "checking %s\n", name);
     
    108143  }
    109144
    110  
    111 
    112145  gprint (GP_ERR, "error: unknown hosts command %s\n", argv[1]);
    113146  return FALSE;
Note: See TracChangeset for help on using the changeset viewer.