IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33223


Ignore:
Timestamp:
Feb 8, 2012, 2:02:25 PM (14 years ago)
Author:
eugene
Message:

fixes to dvodist

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

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/include/dvodist.h

    r33218 r33223  
    2929
    3030// these should be moved to dvo.h?
    31 # define DATA_ON_TGT       0x4000
    32 # define DATA_COPY_FAILURE 0x8000
    33 # define DATA_HOST_ID      0x3fff
     31# define DATA_ON_TGT       0x01
     32# define DATA_COPY_FAILURE 0x02
    3433
    3534/* global variables */
     
    4443void          LockDatabase (char *catdir);
    4544HostTable    *HostTableLoad (char *catdir, char *rootname);
     45int           CheckHostsAndPaths (HostTable *table);
     46
    4647int           AssignSkyToHost (SkyList *skylist, HostTable *table);
    4748int           CopyToHostLocation (char *catdir, SkyList *skylist, HostTable *table);
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/AssignSkyToHost.c

    r33218 r33223  
    1818    // XXX some options;
    1919# if (0)
    20     if (CLEAR_ERRORS && (skylist->regions[i]->hostID & DATA_COPY_FAILURE)) {
     20    if (CLEAR_ERRORS && (skylist->regions[i]->hostFlags & DATA_COPY_FAILURE)) {
    2121      skylist->regions[i]->hostID = 0;
    2222    }
     
    3030
    3131    // assign all regions to one of the Nhost hosts
    32     int N = MAX(table->Nhosts - 1, table->Nhosts * drand48());
     32    float f = drand48();
     33    float n = table->Nhosts * f;
     34    int N = MIN(table->Nhosts - 1, n);
    3335    skylist->regions[i]->hostID = table->hosts[N].hostID;
     36    // fprintf  (stderr, "%f  %f  %d  %d\n", f, n, N, skylist->regions[i]->hostID);
    3437  }   
    3538
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/CopyFromHostLocation.c

    r33218 r33223  
    2929
    3030    // skip catalogs which have not been copied back
    31     if (skylist->regions[i]->hostID & DATA_ON_TGT) continue;
     31    if (skylist->regions[i]->hostFlags & DATA_ON_TGT) continue;
    3232
    3333    // skip catalogs which have an uncleared error
    34     if (skylist->regions[i]->hostID & DATA_COPY_FAILURE) continue;
     34    if (skylist->regions[i]->hostFlags & DATA_COPY_FAILURE) continue;
    3535
    3636    // find the host for the table
    37     int realID = (skylist->regions[i]->hostID & DATA_HOST_ID);
     37    int realID = skylist->regions[i]->hostID;
    3838    short index = table->index[realID];
    3939    HostInfo *host = &table->hosts[index];
     
    111111      // if we failed to make a copy,
    112112         
    113       skylist->regions[i]->hostID |= DATA_COPY_FAILURE;
     113      skylist->regions[i]->hostFlags |= DATA_COPY_FAILURE;
    114114      for (j = 0; success && (j < 4); j++) {
    115115        sprintf (tgtname, "%s/%s.%s", catdir, skylist->regions[i]->name, extname[j]);
     
    118118      Nfailure ++;
    119119    } else {
    120       skylist->regions[i]->hostID &= ~DATA_ON_TGT;
     120      skylist->regions[i]->hostFlags &= ~DATA_ON_TGT;
    121121      for (j = 0; success && (j < 4); j++) {
    122122        sprintf (srcname, "%s/%s.%s", host->pathname, skylist->regions[i]->name, extname[j]);
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/CopyToHostLocation.c

    r33218 r33223  
    1212  char srcname[1024];
    1313  char tgtname[1024];
     14  char outdir[1024];
    1415
    1516  md5_byte_t srcDigest[NDIGEST];
     
    2930
    3031    // skip catalogs which have already been copied
    31     if (skylist->regions[i]->hostID & DATA_ON_TGT) continue;
     32    if (skylist->regions[i]->hostFlags & DATA_ON_TGT) continue;
    3233
    3334    // skip catalogs which have an uncleared error
    34     if (skylist->regions[i]->hostID & DATA_COPY_FAILURE) continue;
     35    if (skylist->regions[i]->hostFlags & DATA_COPY_FAILURE) continue;
    3536
    3637    // find the host for the table
    37     int realID = (skylist->regions[i]->hostID & DATA_HOST_ID);
     38    int realID = skylist->regions[i]->hostID;
    3839    short index = table->index[realID];
    3940    HostInfo *host = &table->hosts[index];
     
    4142    // have to succeed on all 4 tables; if we fail on any one,
    4243    int success = TRUE;
     44
     45    char *subdir = pathname (skylist->regions[i]->name);
     46    sprintf (outdir, "%s/%s", host->pathname, subdir);
     47    free (subdir);
     48
     49    int status = check_dir_access (outdir, DEBUG);
     50    if (!status) {
     51      fprintf (stderr, "failed to find / create target path\n");
     52      exit (2);
     53    }
    4354
    4455    char extname[4][16] = {"cpm", "cpt", "cps", "cpn"};
     
    5263
    5364      // check permission to read file
    54       int status = stat (srcname, &filestat);
    55       if (!status) {
     65      status = stat (srcname, &filestat);
     66      if (status) {
    5667        if (errno == ENOENT) continue;  // file does not exist (handle broken table with cpt + cpm but no cpn,cps?)
    5768        perror ("stat:");
     
    111122      // if we failed to make a copy,
    112123         
    113       skylist->regions[i]->hostID |= DATA_COPY_FAILURE;
     124      skylist->regions[i]->hostFlags |= DATA_COPY_FAILURE;
    114125      for (j = 0; success && (j < 4); j++) {
    115126        sprintf (tgtname, "%s/%s.%s", host->pathname, skylist->regions[i]->name, extname[j]);
     
    118129      Nfailure ++;
    119130    } else {
    120       skylist->regions[i]->hostID |= DATA_ON_TGT;
     131      skylist->regions[i]->hostFlags |= DATA_ON_TGT;
    121132      for (j = 0; success && (j < 4); j++) {
    122133        sprintf (srcname, "%s/%s.%s", catdir, skylist->regions[i]->name, extname[j]);
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/HostTableLoad.c

    r33218 r33223  
    7575      exit (1);
    7676    }
    77     if (ID > 65535) {
     77    if (ID > 255) {
    7878      fprintf (stderr, "invalid host ID %d\n", ID);
    7979      exit (1);
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/dvodist.c

    r33218 r33223  
    1515  char *catdir = strcreate (argv[1]);
    1616
    17   LockDatabase (catdir);
     17  // LockDatabase (catdir);
    1818 
    1919  // load the current SkyTable. If SkyTable does not exist, we must fail
     
    2626    Shutdown ("failed to load Host Table %s for %s\n", catdir, sky->hosts);
    2727  }
     28
     29  CheckHostsAndPaths(hosts);
    2830
    2931  switch (MODE) {
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/initialize_dvodist.c

    r33218 r33223  
    6666  }
    6767  if ((N = get_argument (argc, argv, "-out"))) {
    68     if (!MODE) {
     68    if (MODE) {
    6969      fprintf (stderr, "ERROR: cannot use both -in and -out options!\n");
    7070      usage();
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/md5_ops.c

    r33218 r33223  
    2828    md5_append (&state, buffer, nbytes);
    2929    if (output) {
    30       int nbytesOut = write (fdOutput, buffer, NBUFFER);
    31       // XXX check that we actually write out all nbytes...
     30      int nbytesOut = write (fdOutput, buffer, nbytes);
    3231      if (nbytesOut != nbytes) {
    3332        return FALSE;
     
    3635  }
    3736  md5_finish (&state, digest);
     37
     38# if (0)
     39  int i;
     40  for (i = 0; i < NDIGEST; i++) {
     41    fprintf (stderr, "%02x", digest[i]);
     42  }
     43  fprintf (stderr, " : %s\n", input);
     44# endif
    3845       
    3946  fclose (fInput);
Note: See TracChangeset for help on using the changeset viewer.