home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / test / io / description / test-encode-complex-in.c < prev    next >
C/C++ Source or Header  |  2005-11-11  |  3KB  |  145 lines

  1. /*
  2.  * (C) 2002 Clemson University.
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */       
  6.  
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <assert.h>
  11. #include <sys/types.h>
  12. #include <sys/stat.h>
  13. #include <fcntl.h>
  14. #include <unistd.h>
  15.  
  16. #include <pvfs2-types.h>
  17. #include <gossip.h>
  18. #include <pvfs2-debug.h>
  19. #include <pint-distribution.h>
  20. #include <pint-dist-utils.h>
  21. #include <pvfs2-request.h>
  22. #include <pint-request.h>
  23. #include "pvfs2-internal.h"
  24.  
  25. #define SEGMAX 16
  26. #define BYTEMAX (1024*1024)
  27.  
  28. void Dump_request(PVFS_Request req);
  29.  
  30. int main(int argc, char **argv)
  31. {
  32.     PINT_Request *r_dec;
  33.     int ret = -1;
  34.     int fd = -1;
  35.     PINT_Request_state *rs1;
  36.     PINT_request_file_data rf1;
  37.     PINT_Request_result seg1;
  38.     int retval;
  39.     int i;
  40.  
  41.     fd = open("enc_tmp.dat", O_RDONLY);
  42.     if(fd < 0)
  43.     {
  44.         perror("open");
  45.         return(-1);
  46.     }
  47.  
  48.     /* just make this kindof big, I dunno how large the type is */
  49.     r_dec = (PINT_Request*)malloc(16*1024);
  50.     assert(r_dec);
  51.  
  52.     ret = read(fd, r_dec, (16*1024));
  53.     if(ret < 0)
  54.     {
  55.         perror("read");
  56.         return(-1);
  57.     }
  58.     
  59.     ret = PINT_request_decode(r_dec);
  60.     if(ret < 0)
  61.     {
  62.         fprintf(stderr, "PINT_request_decode() failure.\n");
  63.         return(-1);
  64.     }
  65.     fprintf(stderr, "decode returns %d\n", ret);
  66.  
  67.     /* set up request state */
  68.     rs1 = PINT_new_request_state(r_dec);
  69.  
  70.     /* set up file data for request */
  71.     PINT_dist_initialize(NULL);
  72.     rf1.server_nr = 0;
  73.     rf1.server_ct = 4;
  74.     rf1.fsize = 6000;
  75.     rf1.dist = PINT_dist_create("simple_stripe");
  76.     rf1.extend_flag = 0;
  77.     PINT_dist_lookup(rf1.dist);
  78.  
  79.     /* set up result struct */
  80.     seg1.offset_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  81.     seg1.size_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  82.     seg1.bytemax = BYTEMAX;
  83.     seg1.segmax = SEGMAX;
  84.     seg1.bytes = 0;
  85.     seg1.segs = 0;
  86.         
  87.     printf("\n************************************\n");
  88.     do
  89.     {
  90.         seg1.bytes = 0;
  91.         seg1.segs = 0;
  92.  
  93.         /* process request */
  94.         retval = PINT_process_request(rs1, NULL, &rf1, &seg1, PINT_CLIENT);
  95.  
  96.         if(retval >= 0)
  97.         {
  98.             printf("results of PINT_process_request():\n");
  99.             printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes));
  100.             for(i=0; i<seg1.segs; i++)
  101.             {
  102.                 printf("  segment %d: offset: %d size: %d\n",
  103.                     i, (int)seg1.offset_array[i], (int)seg1.size_array[i]);
  104.             }
  105.         }
  106.  
  107.     } while(!PINT_REQUEST_DONE(rs1) && retval >= 0);
  108.     
  109.     if(retval < 0)
  110.     {
  111.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  112.         return(-1);
  113.     }
  114.     if(PINT_REQUEST_DONE(rs1))
  115.     {
  116.         printf("**** request done.\n");
  117.     }
  118.  
  119.     close(fd);
  120.  
  121.     return 0;
  122. }
  123.  
  124. void Dump_request(PVFS_Request req)
  125. {
  126.     fprintf(stderr,"**********************\n");
  127.     fprintf(stderr,"address:\t%p\n",req);
  128.     fprintf(stderr,"offset:\t\t%d\n",(int)req->offset);
  129.     fprintf(stderr,"num_ereqs:\t%d\n",(int)req->num_ereqs);
  130.     fprintf(stderr,"num_blocks:\t%d\n",(int)req->num_blocks);
  131.     fprintf(stderr,"stride:\t\t%d\n",(int)req->stride);
  132.     fprintf(stderr,"ub:\t\t%d\n",(int)req->ub);
  133.     fprintf(stderr,"lb:\t\t%d\n",(int)req->lb);
  134.     fprintf(stderr,"agg_size:\t%d\n",(int)req->aggregate_size);
  135.     fprintf(stderr,"num_chunk:\t%d\n",(int)req->num_contig_chunks);
  136.     fprintf(stderr,"depth:\t\t%d\n",(int)req->depth);
  137.     fprintf(stderr,"num_nest:\t%d\n",(int)req->num_nested_req);
  138.     fprintf(stderr,"commit:\t\t%d\n",(int)req->committed);
  139.     fprintf(stderr,"refcount:\t\t%d\n",(int)req->refcount);
  140.     fprintf(stderr,"ereq:\t\t%p\n",req->ereq);
  141.     fprintf(stderr,"sreq:\t\t%p\n",req->sreq);
  142.     fprintf(stderr,"**********************\n");
  143. }
  144.  
  145.