IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33240


Ignore:
Timestamp:
Feb 10, 2012, 1:54:34 PM (14 years ago)
Author:
eugene
Message:

moving DVO parallel host info into

Location:
branches/eam_branches/ipp-20111122/Ohana/src/photdbc
Files:
3 edited

Legend:

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

    r33218 r33240  
    1 default: photdbc
     1default: photdbc dvodist
    22help:
    33        @echo "make options: photdbc (default)"
     
    3636$(SRC)/Shutdown_dvodist.$(ARCH).o       \
    3737$(SRC)/SetSignals.$(ARCH).o             \
    38 $(SRC)/rconnect.$(ARCH).o               \
    3938$(SRC)/md5_ops.$(ARCH).o                \
    4039$(SRC)/md5.$(ARCH).o                    \
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/include/dvodist.h

    r33223 r33240  
    55# include <unistd.h> // needed?
    66
    7 # define myAssert(LOGIC,MSG) { if (!(LOGIC)) { fprintf (stderr, "%s\n", MSG); abort(); } }
    8 
    97// used by the md5 stuff
    108# define NDIGEST  16
    11 
    12 typedef enum {
    13     MODE_NONE = 0,
    14     MODE_OUT  = 1,
    15     MODE_IN   = 2,
    16 } ModeType;
    17 
    18 typedef struct {
    19   char *hostname;
    20   char *pathname;
    21   int hostID;
    22 } HostInfo;
    23 
    24 typedef struct {
    25   int Nhosts;
    26   HostInfo *hosts;
    27   unsigned short *index;
    28 } HostTable;
    29 
    30 // these should be moved to dvo.h?
    31 # define DATA_ON_TGT       0x01
    32 # define DATA_COPY_FAILURE 0x02
    339
    3410/* global variables */
     
    4218
    4319void          LockDatabase (char *catdir);
    44 HostTable    *HostTableLoad (char *catdir, char *rootname);
    4520int           CheckHostsAndPaths (HostTable *table);
    4621
     
    5429void          SetProtect (int mode);
    5530int           SetSignals (void);
    56 int           rconnect (char *command, char *hostname, char *shell, int *stdio);
    5731
    58 int           write_fmt (int fd, char *format, ...);
    59 char         *memstr (char *m1, char *m2, int n);
    6032int           get_md5_with_copy (char *input, char *output, md5_byte_t *digest);
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/HostTableLoad.c

    r33223 r33240  
    11# include "dvodist.h"
    22# define DEBUG 1
    3 
    4 void InitHosts (HostInfo *hosts, int Nhosts, int NHOSTS) {
    5 
    6   int i;
    7   for (i = Nhosts; i < NHOSTS; i++) {
    8     hosts[i].hostname = NULL;
    9     hosts[i].pathname = NULL;
    10   }
    11   return;
    12 }
    13 
    14 void FreeHosts (HostInfo *hosts, int Nhosts) {
    15 
    16   int i;
    17   for (i = 0; i < Nhosts; i++) {
    18     free (hosts[i].hostname);
    19     free (hosts[i].pathname);
    20   }
    21   free (hosts);
    22   return;
    23 }
    24 
    25 HostTable *HostTableLoad (char *catdir, char *rootname) {
    26 
    27   int i, Nline;
    28 
    29   char *filename = NULL;
    30 
    31   ALLOCATE (filename, char, strlen(catdir) + strlen(rootname) + 2); // one slash and one EOL
    32   sprintf (filename, "%s/%s", catdir, rootname);
    33 
    34   FILE *f = fopen (filename, "r");
    35   if (!f) {
    36     fprintf (stderr, "failed to open host table %s\n", filename);
    37     return NULL;
    38   }
    39 
    40   // simple format: ID hostname pathname
    41  
    42   int NHOSTS = 16;
    43   int Nhosts = 0;
    44   HostInfo *hosts = NULL;
    45   ALLOCATE (hosts, HostInfo, NHOSTS);
    46   InitHosts (hosts, Nhosts, NHOSTS);
    47 
    48   int maxID = 0;
    49 
    50   for (Nline = 0; TRUE; Nline ++) {
    51     int ID;
    52     char tmphost[1024];
    53     char tmppath[1024];
    54     char line[1024];
    55 
    56     // XXXX use this for safety: int status = scan_line_maxlen (f, line, 1024);
    57     int status = scan_line (f, line);
    58     if (status == EOF) break;
    59 
    60     // find first non-whitespace char & skip commented lines
    61     for (i = 0; OHANA_WHITESPACE (line[i]); i++);
    62     if (line[i] == '#') continue;
    63 
    64     status = sscanf (line, "%d %1023s %1023s", &ID, tmphost, tmppath);
    65     if (status != 3) {
    66       fprintf (stderr, "error reading line %d of host table %s\n", Nline, filename);
    67       FreeHosts (hosts, Nhosts);
    68       return NULL;
    69     }
    70 
    71     // check the validity of ID (0 < ID < MAX_SHORT)
    72 
    73     if (ID < 1) {
    74       fprintf (stderr, "invalid host ID %d\n", ID);
    75       exit (1);
    76     }
    77     if (ID > 255) {
    78       fprintf (stderr, "invalid host ID %d\n", ID);
    79       exit (1);
    80     }
    81     maxID = MAX(maxID, ID);
    82 
    83     hosts[Nhosts].hostID = ID;
    84     hosts[Nhosts].hostname = strcreate(tmphost);
    85     hosts[Nhosts].pathname = strcreate(tmppath);
    86    
    87     Nhosts ++;
    88     if (Nhosts >= NHOSTS) {
    89       NHOSTS += 16;
    90       REALLOCATE (hosts, HostInfo, NHOSTS);
    91       InitHosts (hosts, Nhosts, NHOSTS);
    92     }
    93   }   
    94 
    95   HostTable *table = NULL;
    96   ALLOCATE (table, HostTable, 1);
    97   table->Nhosts = Nhosts;
    98   table->hosts = hosts;
    99 
    100   ALLOCATE (table->index, unsigned short, maxID + 1);
    101   for (i = 0; i <= maxID; i++) table->index[i] = -1;
    102 
    103   for (i = 0; i < table->Nhosts; i++) {
    104     if (table->index[table->hosts[i].hostID] == -1) {
    105       fprintf (stderr, "error: duplicate hostID %d\n", table->hosts[i].hostID);
    106       exit (1);
    107     }
    108     table->index[table->hosts[i].hostID] = i;
    109   }
    110 
    111   return table;
    112 }
    1133
    1144int CheckHostsAndPaths (HostTable *table) {
     
    12717    if (DEBUG) fprintf (stderr, "starting host within thread\n");
    12818
    129     int pid = rconnect (command, table->hosts[i].hostname, shell, stdio);
     19    int errorInfo;
     20    int pid = rconnect (command, table->hosts[i].hostname, shell, stdio, &errorInfo, TRUE);
    13021    if (!pid) {     
    13122      /** failure to start: extend retry period **/
    132       if (DEBUG) fprintf (stderr, "failure to start %s\n", table->hosts[i].hostname);
     23      if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo);
    13324      exit (1);
    13425    }
Note: See TracChangeset for help on using the changeset viewer.