Changeset 34119
- Timestamp:
- Jul 5, 2012, 9:11:28 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120627/Ohana/src/opihi/dvo
- Files:
-
- 2 edited
-
dvo_host_utils.c (modified) (3 diffs)
-
hosts.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120627/Ohana/src/opihi/dvo/dvo_host_utils.c
r33963 r34119 15 15 snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000); 16 16 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 17 36 int top_status = TRUE; 18 37 int i; … … 29 48 snprintf (table->hosts[i].results, DVO_MAX_PATH, "%s/dvo.results.%s.fits", table->hosts[i].pathname, uniquer); 30 49 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 disk45 int state;46 f = fsetlockfile (commandFile, 0.5, LCK_XCLD, &state);47 fclearlockfile (commandFile, f, LCK_XCLD, &state);48 49 50 char command[1024]; 50 51 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);52 52 53 53 if (VERBOSE) gprint (GP_ERR, "command: %s\n", command); … … 75 75 } 76 76 } 77 free (commandFile); 77 78 return top_status; 78 79 } -
branches/eam_branches/ipp-20120627/Ohana/src/opihi/dvo/hosts.c
r34088 r34119 2 2 # include <glob.h> 3 3 # define DVO_MAX_PATH 1024 4 5 enum {TEMP_NONE, TEMP_DVO_RESULTS, TEMP_DVO_LOG, TEMP_RELPHOT_RESULTS, TEMP_RELPHOT_LOG}; 4 6 5 7 // functions to manage the remote hosts … … 10 12 gprint (GP_ERR, " commands:\n"); 11 13 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"); 12 16 return FALSE; 13 17 } … … 27 31 remove_argument (N, &argc, argv); 28 32 ALL_PID = TRUE; 29 remove_argument (N, &argc, argv);30 33 } 31 34 … … 46 49 } 47 50 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 48 72 // XXX wrap this up in a function: 49 73 char *CATDIR = GetCATDIR(); … … 63 87 } 64 88 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 65 94 int i; 66 95 for (i = 0; i < table->Nhosts; i++) { … … 68 97 char name[DVO_MAX_PATH]; 69 98 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); 71 103 } 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); 73 108 } 74 109 if (VERBOSE) gprint (GP_ERR, "checking %s\n", name); … … 108 143 } 109 144 110 111 112 145 gprint (GP_ERR, "error: unknown hosts command %s\n", argv[1]); 113 146 return FALSE;
Note:
See TracChangeset
for help on using the changeset viewer.
